c# - Hide Panel on Child MasterPage Inside MasterPage ContentPlaceHolder using Child Content Page -


i've tried find solution everywhere, unable make work.

i have following code.

masterpage.master:

<%@ master language="c#" autoeventwireup="true" codefile="masterpage.master.cs" inherits="my_masterpage" %>  <asp:contentplaceholder id="contentplaceholder1" runat="server"></asp:contentplaceholder> 

childmasterpage.master:

<%@ master language="c#" masterpagefile="~/masterpage.master" autoeventwireup="true" codefile="childmasterpage.master.cs" inherits="my_childmasterpage" %> <%@ register tagprefix="uc1" tagname="filedirectoryorganizer" src="~/controls/my.ascx" %>   <asp:content id="content7" contentplaceholderid="contentplaceholder1" runat="server">  <asp:panel id="sidenav" runat="server">      <aside id="sidebar">          there 2 user controls <asp:uc1> inside of area      </aside>  </asp:panel>  <div>     <asp:contentplaceholder id="contentbody" runat="server" />     <hr />     <h3>related topics</h3> </div>  </asp:content> 

my.aspx:

<%@ page title="" language="c#" masterpagefile="~/subdirectory/childmasterpage.master" autoeventwireup="true" codefile="my.aspx.cs" inherits="subdirectory_my" %> <%@ mastertype virtualpath="~/subdirectory/childmasterpage.master" %> <%@ reference virtualpath="~/masterpage.master" %>  <asp:content id="content1" contentplaceholderid="contentbody" runat="server"> </asp:content> 

i've tried following in my.aspx code behind hide "sidenav" panel childmasterpage.master:

1)

protected void page_load(object sender, eventargs e) {     contentplaceholder cpholder = this.master.findcontrol("content7") contentplaceholder;     panel p = cpholder.findcontrol("sidenav") panel;     p.visible = false; } 

2)

protected void page_load(object sender, eventargs e) {     contentplaceholder cpholder = this.master.findcontrol("contentplaceholder1") contentplaceholder;     panel p = cpholder.findcontrol("sidenav") panel;     p.visible = false; } 

3)

protected void page_load(object sender, eventargs e) {     panel p = this.master.findcontrol("sidenav") panel;     p.visible = false; } 

all of these give me following error when trying load aspx page uses childmasterpage:

 500 - internal server error.  there problem resource looking for, , cannot displayed. 

ultimately, i'd display none style space not used on aspx page. this, gives me same error above:

protected void page_load(object sender, eventargs e) {     ((panel)this.page.master.findcontrol("sidenav")).style.add("display", "none"); } 

thank in advance assistance may offer. also, apologize in advance if question has been answered here already, unable find it. @ least nothing worked. i'm still not c#, i'm getting there.

thanks

mark

i think have type cast content control contentplaceholder control in first approach.

i believe code should below:

content cpholder = this.master.findcontrol("content7") content; 

hope !!


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -