1

I have a hidden control (an asp.net label) and want to show it when a user clicks a button.

Here is the hidden control

<asp:Label ID="lblCityRequired" visible="False" runat="server" Text="Required if Country  State are selected"></asp:Label>

Here is the javascript code

function showLabel()
{
    $("#lblCityRequired").show();
}

function hideLabel()
{
    $("#lblCityRequired").hide();
}

This only works when the label's visibility is not set to false. However I want the form to start up hiding the message. Is there something I am doing wrong? Should I just create a javascript function that starts up hiding the label via javascript?

Thanks in advance

2
  • 1
    when the control is set to false, it is not rendered in the client. you can try setting a display:none on the control to make it work. Commented May 8, 2015 at 16:34
  • 1
    Adding style attribute to the tag style="display:none"? Commented May 8, 2015 at 16:36

1 Answer 1

1

You can hide it initally when dom is ready:

 $(function(){
     hideLabel();
 })

Or, you can use css:

 <style>#lblCityRequired{display:none;}</style>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.