Click here to Skip to main content
15,885,874 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i click on login button then a div is display in the screen color in black and one other popup is display for login. Login popup contain one close button.
i want to hide that opened popup or div on that close button click on code behind side
thaks for help
Posted
Updated 17-Feb-15 0:45am
v2

U can hide your div using c# code.

ASP.NET
<div id="div1" runat="server"> 
//put runat="server" in the div otherwise u can't get the div id in code behind.</div>


//in code behind

C#
div1.visible = false // hiding the div

div1.visible = true // showing the div
 
Share this answer
 
The other solutions are correct in setting runat=server and then hide the div from the server. But the div you intend to hide can contain elements which may be referenced somewhere in your script and your javascript will throw null reference error if they are not there on the page.

To avoid that use the following code:

C#
yourDiv.Style.Add(HtmlTextWriterStyle.Display, "none");

This sets Display css property to none to hide the div instead of not adding the element entirely.

This approach is much cleaner and safe then just setting visibility to false.
 
Share this answer
 

all other controls


I believe the base class for all ASP.NET WebForms controls is HtmlControl which has a Visible property.

sample-div.visible = false;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900