Click here to Skip to main content
15,921,226 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Respected Sir/Mam

i am using asp:menu


i want to hide master page's div when i click on asp;menu

that div show only the home page not on other page .
Posted

you can find a master page control from content page like this

//your div should contain the property
runat="server"


//finding the div associated with id
System.Web.UI.HtmlControls.HtmlGenericControl currdiv = (System.Web.UI.HtmlControls.HtmlGenericControl)Master.FindControl("divid");


//hiding the div
currdiv.Style.Add("display", "none");
 
Share this answer
 
v2
Try this

HtmlGenericControl DivCount = (HtmlGenericControl)Page.Master.FindControl("MainH").FindControl("DivCount");
 DivCount.Visible = false;
 
Share this answer
 
v2
Use runat="server" with div tag and id then you can hide div from code behind
You can hide this div on any page which link to that particular Master page
For Example:-
 

DIVID.visible=false;

C#
<div id="DIVID"   runat="server">
 
Share this answer
 
v3
In master page you place that div on contentplaceholder like this 

C#
<asp:ContentPlaceHolder id="ContentPlaceHolder2" runat="server">
  <div>
    example div
  </div>

//After that on content page you set the property visible="false" 

C#
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server" Visible="false">
 
Share this answer
 
v3
im also missing runat server in my div
now its working fine
 
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