Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having a problem with my asp.net label control when trying to modify its content using javascript.


I am using
document.getElementById('<%= lblPayslipErr.ClientID %>')
to set the HTML content of the label.
I tried to set a static text in the label and alert it via javascript and it is working and being detected, however when I try to use .innerHTML to the label, console says variable lbl it is null.


This asp label control is in a row of a 2nd grid view inside another grid view control

What I have tried:

HTML
function uploadError(sender, args) {
alert(document.getElementById('<%= lblPayslipErr.ClientID %>').innerHTML); <%--This works, the label text is being prompted--%>

var lbl = document.getElementById('<%= lblPayslipErr.ClientID %>');

lbl.innerHTML = "Check file size or file extension.";  <%--I am setting the innerHTML of the label here but it does not work.--%>
Posted
Updated 30-Aug-20 15:28pm
v3

1 solution

I think - this should be your problem:
HTML
var lbl document.getElementById('<%= lblPayslipErr.ClientID %>');
You missed an equal operator here:
HTML
var lbl = document.getElementById('<%= lblPayslipErr.ClientID %>');


Try!
 
Share this answer
 
Comments
bjay tiamsic 30-Aug-20 21:27pm    
hello. it still does not work. I may have erased the equal sign whilst editing my post

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900