Reputation: 2012
I have a label in a div which I want to show or hide depending on the value of another text box the JavaScript function is written and working but in the ASP.NET code behind I use a select case statement to set the DIVid.Visible
to True
or False
on the page load.
The javascript function for hiding the div only works when on the load it the DIVid.Visible is true the other parts of the JS function (disable a text box) work fine.
Is it something to do with because it can't find the DIVid because visible is false and how would I overcome this?
Upvotes: 1
Views: 331
Reputation: 4922
Set div style attribute not .net control visibility property.
yourDiv.Attributes.Add("style", "display: none;");
Upvotes: 2
Reputation: 21825
When you say DIVid.Visible = false
in ASP.NET, that control is not rendered so you won't be able to manipulate it using Javascript.
If for some reason, you want to handle the visibility at server side then you can add attributes like this:-
DIVid.Attributes.Add("style","display:none;");
Upvotes: 2