简体   繁体   中英

ASP.Net C# Master Site

I have a question about the ****.Master Site a in ASP.NET with C# (WebForms). I've created a Site.Masters File with a lot of differente Placeholders inside. So the question is - is it possible to fill the Placeholders from different .aspx Files?

.Master Page:

    <asp:ContentPlaceHolder ID="MainHeader" runat="server">

    </asp:ContentPlaceHolder>

    <asp:ContentPlaceHolder ID="MainContent" runat="server">

    </asp:ContentPlaceHolder>

    <asp:ContentPlaceHolder ID="MainFooter" runat="server">

    </asp:ContentPlaceHolder>
</div>

Now i would do something like this:

  1. Adding some Content to the Main Header - the Content is represented in a file called mainHeader.aspx
  2. Adding some Content to the Main Content - the Content is represented in a file calle mainContent.apsx

Is this possible or is there a solution for my plan? I would like to create a modular and flat structure of my .NET Project.

Thanks for your help - best regards

No, that's not how Master Pages work.

When the user/client requests an individual content Page, that Page is merged with the Master Page. The Master Page can not be called by the user/client.

I believe User Controls are what you are looking for.

You can do what you want by using jquery.load(), here is the documentation http://api.jquery.com/load/ , however i think what you are doing is not the way to procede, in order to do what you want i suggest yo to do this:

Create User Controls, one for each master ContentPlaceHolder, then in your master, add each one of this and initiate them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM