Click here to Skip to main content
15,847,750 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
hello friends i want to use div tag visible and invisible in codebehind... but its not coming which namespace i have to use...
Posted

try this :)
XML
<div id = "testDiv"  runat="server">sample text
            </div>

C#
protected void Button1_Click(object sender, EventArgs e)
{
            testDiv.Visible = false;
}
 
Share this answer
 
v3
Comments
beginner in C#.net 11-May-11 4:26am    
ya i missed runat command... thats y its was not workin..
my 5
ambarishtv 11-May-11 4:40am    
thanks
amol ghadge 22-Apr-15 2:43am    
Thank You So much Dear.....Wonderful.... help....
try this,

XML
<div id="content" runat="server">
    </div>


C#
protected void Page_Load(object sender, EventArgs e)
    {
         if (!IsPostBack)
            {
               content.Visible = false;
            }

    }


Or

If your div is inside GridView or Repeater or any control,Then you can find it like this,

HtmlGenericControl InnerDiv = (HtmlGenericControl)e.Item.FindControl("divName");


I hope this will help you.
 
Share this answer
 
Comments
beginner in C#.net 12-May-11 2:49am    
thanks..
you can add label or textbox which have a visibility property.
i think it makes simplier that way
 
Share this answer
 
Stop suggesting runat="server"

there are many instances where it causes issues and suggesting it shows you have little experience
 
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