I Have a asp label
<asp:Label ID="lblstarUKRollNo" Visible="false" runat="server" Text="*" CssClass="star"></asp:Label>
and i want to enable it onchange of another textbox which calls a JS, in my javascript i tried
var idlblstarUKRollNo = '<%= lblstarUKRollNo.ClientID %>';
var lblstarUKRollNo = document.getElementById(idlblstarUKRollNo);
and to enable
reqdddlUKJurisdiction.enabled = true;
and lblstarUKRollNo.style.display="block";
Both did not work for me. Can anyone help me How to solve this issue.
I Have a asp label
<asp:Label ID="lblstarUKRollNo" Visible="false" runat="server" Text="*" CssClass="star"></asp:Label>
and i want to enable it onchange of another textbox which calls a JS, in my javascript i tried
var idlblstarUKRollNo = '<%= lblstarUKRollNo.ClientID %>';
var lblstarUKRollNo = document.getElementById(idlblstarUKRollNo);
and to enable
reqdddlUKJurisdiction.enabled = true;
and lblstarUKRollNo.style.display="block";
Both did not work for me. Can anyone help me How to solve this issue.
Share Improve this question asked Apr 2, 2012 at 10:25 IshanIshan 4,02832 gold badges95 silver badges157 bronze badges 1- 1 Just look what visible actually does msdn.microsoft./en-us/library/… – Sly Commented Apr 2, 2012 at 10:32
4 Answers
Reset to default 4If you set Visible
property to false on a server-control it wont be rendered on the client side at all. So javascript wont be able to find it. Remove Visible
property; just use css style "display:none
"; later use javascript to change it as "display:block"
Guidance from another question
After adapting to your case:
<asp:Label id="lblstarUKRollNo" style="display: block;" runat="server" Text="*" CssClass="star"/>
Then, you could make it invisible on the client side on Javascript with:
document.getElementById('lblstarUKRollNo').style.display = 'none';
Try using jQuery - $('.someElement').attr('disabled', '');
In addition to what @mshsyayem above has said you have to set the display to none. and you can do it in the code-behind by using the attributes. See below.
lblstarUKRollNo.Attributes.Add("style", "display:none");
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745273792a4619909.html
评论列表(0条)