Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

Get the label name with Javascript/ASP.Net

This is related to the question i asked here but i closed that question:
https://www.experts-exchange.com/questions/22490183/Checking-for-length-of-strings-in-Javascript.html

I have a label with id="lblHPhone" and text="Home Phone"
I want to get the text and tried this:
  var test = document.getElementById('<%= Page.Master.FindControl("ContentPlaceHolder1").FindControl("lblHPhone").ClientID %>');
        alert(test.value);

But I get "undefined" for that...how can I get the label name??
ASKER CERTIFIED SOLUTION
Avatar of gops1
gops1
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How is your label defined ?
Something like this:
<input type="text" name="lblHPhone" id="lblHPhone">  ?

Also ensure that there is only one element with the name lblHPhone