asp.net - Enable a ASP hidden label in Javascript - Stack Overflow

I Have a asp label<asp:Label ID="lblstarUKRollNo" Visible="false" runat="se

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
Add a ment  | 

4 Answers 4

Reset to default 4

If 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

相关推荐

  • asp.net - Enable a ASP hidden label in Javascript - Stack Overflow

    I Have a asp label<asp:Label ID="lblstarUKRollNo" Visible="false" runat="se

    1小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信