tags:

views:

65

answers:

3

I have a Div with runat attribut="server" .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 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.I want to Show that hided div from my javascript

Any thoughts ? Thanks in advance

+4  A: 

Add a display:none CSS style to the control:

myDiv.Style.Add(HtmlTextWriterStyle.Display, "none");
Mehrdad Afshari
A: 

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.

Matthew Flaschen
He's talking about the visible property of an asp.net server or hybrid control.
Joel Coehoorn
Yes, but setting the visibility false in server side code (this.myDiv.Visible = false;) will remove it from the DOM. I believe Shyju wants to avoid this, in which case I would use (this.myDiv.Style["display"] = "none";)
Robert Claypool
It is possible to set the CSS visibility property from the server as well.
Matthew Flaschen
A: 

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.

Joel Coehoorn