ASP.NET control with visible=false cannot be used in javascript? ASP.NET control with visible=false cannot be used in javascript? asp.net asp.net

ASP.NET control with visible=false cannot be used in javascript?


When you set Visible = false to a control, it is not rendered. That means there is no HTML representation of that control sent to the page. Set the style only.

You can set the style as display: none from server side code like this:

FromDate.Style.Add(HtmlTextWriterStyle.Display, "none")


If you want to hide this control, you can try CSS like this:

<asp:somecontrol id="FromDate" style="display:none" />

I think hiding the control with CSS is easier to understand.


Instead of setting Visible=false, set its style.display to none, that way the element is still there for JavaScript to manipulate.