Search code examples
htmlasp.nettabsmaster-pagescontentplaceholder

Is it possible to link several aspx files to one content placeholder and switch between them?


I am quite new to asp.net and currently trying to create website with info about trekking. It will cover 6 areas and each area will have further sections General info, Sights and Treks.

On highest level I have Master page with menu with 6 items (Area1 - Area6). After clicking one of the items clickedArea is saved into session and nested masterpage opens. It contains Tab with 3 items (General info, Sights, Treks) and content placeholder containing General info page. What I want to achieve is that after clicking on another Tab will system read clickedArea from session and display correct content page in placeholder.

So in the end I would like to have 18 .aspx content pages, which would be displayed in lowest-level placeholder dynamically based on clickedArea and clickedTab. I guess I could do it with 18 placeholders, but I am looking for better solution with three or even one content placeholder. Could someone help me? For better understanding, my nested Mastep page looks like this. How could I achieve dynamic loading of pages into those placeholders? Or is there some other way to do it?

 *<%@ Master Language="C#" MasterPageFile="./Site1.master" AutoEventWireup="true" 
CodeBehind="Regions.Master.cs" Inherits="Travels.Areas" %>
        <asp:Content ID="Content1" ContentPlaceHolderID="Content1" Runat="Server">

        <div id="tabs">
        <ul>
        <li><a href="#tabs-1">General</a></li>
        <li><a href="#tabs-2">Sights</a></li>
        <li><a href="#tabs-3">Treks</a></li>
        </ul>
        <div id="tabs-1">
            <asp:ContentPlaceHolder ID="General" runat="server"></asp:ContentPlaceHolder> 
        </div>
        <div id="tabs-2">
            <asp:ContentPlaceHolder ID="Sights" runat="server"></asp:ContentPlaceHolder> 
        </div>
        <div id="tabs-3">
            <asp:ContentPlaceHolder ID="Treks" runat="server"></asp:ContentPlaceHolder> 
        </div>
        </div>
        </asp:Content>*

Thank you, Jozef


Solution

  • I finally found a solution - used Parent and Child menu linked to web.sitemap.

    <asp:SiteMapDataSource ID="smMaster" runat="server" ShowStartingNode="false" />
       <asp:SiteMapDataSource ID="smChild" runat="server" ShowStartingNode="false" StartFromCurrentNode="true" />
    

    now are data dispalyed correctly