Reputation: 218952
I have a div with runat="server"
set. I have an ASP.NET button control in my page. When this button is clicked, I want to hide the div.
Is there any other option that setting visible="false"
?
I can't use that, because when I do, I can't access the element in my JavaScript since it is removed from the browser. I want to show the hidden div with JavaScript at a later point.
Upvotes: 2
Views: 1970
Reputation: 416149
If that's the only thing your button does, I'd probably do it in javascript first to avoid the postback all together.
If that's not an option, then just add the style attribute to the div server-side with "display:none;
" for the value.
Upvotes: 0
Reputation: 285077
Is there any other option that changing visibility to false.I cant use the visibility to false,because when i change visibility,I cant access the same in my javascript since it is removed from the browser.
This doesn't make sense. Setting the CSS visibility to hidden will not remove the element from the DOM.
Upvotes: 0
Reputation: 422310
Add a display:none
CSS style to the control:
myDiv.Style.Add(HtmlTextWriterStyle.Display, "none");
Upvotes: 6