Peter Chan
asked on
Way to get value of Label
Hi,
Further to this
https://www.experts-exchange.com/questions/29045050/Problem-to-delete-record.html?anchor=a42223836¬ificationFollowed=192790883&anchorAnswerId=42223836#a42223836
how to adjust the codes to be able to get value of Label, in JS codes.
Further to this
https://www.experts-exchange.com/questions/29045050/Problem-to-delete-record.html?anchor=a42223836¬ificationFollowed=192790883&anchorAnswerId=42223836#a42223836
how to adjust the codes to be able to get value of Label, in JS codes.
ASKER
Sorry, I did declare the Label on page. How to adjust this
to refer to the Label
var site_lang = document.getElementById("<%= lb_site_lang.ClientID %>").innerHTML;
to refer to the Label
there is no such thing on the page, so you cannot get the value of it :)
where is the code for that element?
where is the code for that element?
ASKER
I have
<asp:Label ID="lb_site_lang"
Visible="false"
Style="display: none"
Font-Names="Times New Roman"
Font-Size="11pt"
Font-Bold="true"
ForeColor="DarkBlue"
ClientIDMode="Static"
runat="server" />
on page, and due to that it is not Visible, thus you do not see it on the page
Visible="false"
means DO NOT RENDER it!
it will not be on page, just use style...
also, why do you need label for this?
use hidden element
and set the value on your page as
then you can use
but the issue is, you cannot use "<%= lb_site_lang.ClientId %>" in external js files!
means DO NOT RENDER it!
it will not be on page, just use style...
also, why do you need label for this?
use hidden element
<asp:HiddenField ID="lb_site_lang" runat="server" value=""/>
and set the value on your page as
lb_site_lang.value = "ENG"
then you can use
var site_lang = document.getElementById("<%= lb_site_lang.ClientId %>").value;
but the issue is, you cannot use "<%= lb_site_lang.ClientId %>" in external js files!
to fix that, we can use class
css
and js
<asp:Label ID="lb_site_lang"
cssClass="siteLanguage"
ClientIDMode="Static"
runat="server" />
css
siteLanguage {
display:none
}
and js
var site_lang = document.getElementById("lb_site_lang %>").innerHTML;
ASKER
I have
<asp:HiddenField ID="hf_site_lang" runat="server" value=""/>
...
success: function (response) {
var site_lang = document.getElementById("<%= hf_site_lang.ClientId %>").value;
but I still cannot show the list, after re-deployment, due to current change.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Good day HainKurt,
If available, can you please see this below?
https://www.experts-exchange.com/questions/29045779/Adjust-the-area.html
If available, can you please see this below?
https://www.experts-exchange.com/questions/29045779/Adjust-the-area.html
http://my-friend.co/Test_rec4/JavaScript1.js, Line 158
Open in new window
1. there is no such element on the page - lb_site_lang
2. you cannot use <%= ... %> on a js file
here is the site for reference
http://my-friend.co/Test_rec4/Default.aspx?userid=mc23