Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get value in javascript for asp Label control?

Suppose I have asp Lable set in markup like:

<asp:Label ID="myID" runat="server"></asp:Label>

then set value for this Label in code behind like:

myID.Text =100

then I want get the value 100 in javascript. I tried:

document.getElementById('<%=myID.ClientID%>').value; 

but is not working. How to resolve this issue?

like image 820
KentZhou Avatar asked Mar 21 '23 22:03

KentZhou


1 Answers

I believe that labels render as spans. Try getting the inner text.

document.getElementById('<%=myID.ClientID%>').innerText;
like image 196
Smeegs Avatar answered Mar 31 '23 19:03

Smeegs