Need help preventing display of some master page content on one .aspx page

Last post 12-04-2008 4:55 AM by zcon_sachin@hotmail.com. 3 replies.

Sort Posts:

  • Need help preventing display of some master page content on one .aspx page

    12-02-2008, 7:48 PM
    • Member
      point Member
    • castrohouse
    • Member since 12-03-2008, 12:08 AM
    • Posts 2

    As a complete novice,  I am using a similar starter kit (BlogEngine.Net).  I have a master page (site.master) that controls the general layout for the rest of my .aspx pages.  I want all the pages to display the same general content except for one page (home.aspx).  I would like part of the masterpage content hidden on home.aspx.  Is there a way to write a conditional statement in the master page that will allow or disallow some of the master page content to be displayed based on which .aspx file is active?

    If home.aspx is the active page, then hide part of site.master contents.  Else-If home.aspx is not the active page, then display all the contents of site.master.

    Below are partial contents of site.master (my master page).   There is an if statement (bolded below) dealing with site administration stuff that displays administrator content when logged into the site (makes me think my idea is possible).  When home.aspx is active, I would like to hide the content that is lined out.

    <body>
        <form id="form1" runat="server">
            <div id="menu">
                <ul>
                  <li><a id="A1" href="~/home.aspx" runat="server"><%=Resources.labels.home %></a></li>
                  <li><a id="A2" href="~/about.aspx" runat="server"><%=Resources.labels.about %></a></li>
                  <li><a id="A3" href="~/default.aspx" runat="server" rel="home"><%=Resources.labels.blog %></a></li>
                  <li><a id="A4" href="~/contact.aspx" runat="server"><%=Resources.labels.contact %></a></li>
                  <li><a id="A5" href="~/archive.aspx" runat="server"><%=Resources.labels.archive %></a></li>
                </ul>
            </div>

            <div id="main">
                <div class="sidecol" id="sidebar">
                    <ul>               
                        <li>
                            <h2>About</h2>
                        </li>
                        <% if (Page.User.Identity.IsAuthenticated){ %>
                        <li>
                            <h2>Administration</h2>
                            <uc1:menu ID="Menu1" runat="server" />
                        </li>
                        <%} %>

                        <li>
                            <h2>Disclaimer</h2>
                        </li>

                    </ul>
                </div>
            </div>
        </form>
    </body>

                         

  • Re: Need help preventing display of some master page content on one .aspx page

    12-03-2008, 12:19 AM

     make that li item as the runat server, in content  (home) page you can find the master page contents by id.

    Find the li item id and make it visibility false

    to find the master page contents user Page.Master.FindControl("ID").Visibility = false;

  • Re: Need help preventing display of some master page content on one .aspx page

    12-04-2008, 1:40 AM
    • Member
      point Member
    • castrohouse
    • Member since 12-03-2008, 12:08 AM
    • Posts 2

     The lined out content in the code above is contained in the site.master file.  I want to prevent this lined out code from the .master file from displaying when home.aspx calls on the .master file.

  • Re: Need help preventing display of some master page content on one .aspx page

    12-04-2008, 4:55 AM

    replace your master page lined out contents by bellow 3 lines code 

    <li runat="server" id="li1">

             <h2> Disclaimer</h2>

    </li>

     and

    on your home page 

    find the above li item by its id "li1" from home.aspx page and make its visibility false in home.aspx page

Page 1 of 1 (4 items)
Microsoft Communities