Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi dear's,
i wrote a div html code in sitemaster,
then,i add a form using sitemaster(frmTest.aspx),
frmtest have a button(btnTest),
i want when i click on the btnTest,the dive on the sitemaster hide,
thank's.
Posted

if your div and button is server side tags use this on your buttons click
C#
protected void btnTest_Click(object sender, EventArgs e)
{
 HtmlContainerControl div= (HtmlContainerControl)this.Master.FindControl("your_div_in_maste_page");
  div.Visible = false;
}
 
Share this answer
 
I am providing you and example for toggling your div but you can use this approach for only show/hide.

For example you have a Div within MasterPage like the following:
HTML
<div id="myDivBox" style="display:none; width :300px">
          For hiding and showing your div dynamically via JavaScript. This content will toggle.
        </div>

And you have a Button within Child Page which inherits that MasterPage:
ASP.NET
<asp:button id="button1" runat="server" onclick="toggleDiv()" />

Now write the following scripts within ContentPlaceHolder:
XML
<script language="javascript" type="text/javascript">
       function toggleDiv()
       {
         if (document.getElementById("myDivBox").style.display == "block")
         {
           document.getElementById("myDivBox").style.display = "none";
         }
         else
         {
           document.getElementById("myDivBox").style.display = "block";
         }
       }
     </script>


For further detail please navigate the following links:

Show hide div on button click without postback
How to hide, show, or toggle your div

You will find more examples on Google.
 
Share this answer
 
v3
Comments
Sandeep Mewara 27-May-12 1:34am    
Yep. 5!
Monjurul Habib 27-May-12 2:26am    
thank you

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