Question

In a LogOn view, I have the following code:

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

What does this fragment mean and where is "MainContent" defined?

EDIT

Thanks for your replies. I now understand how it works, but where is "MainContent" defined? Is it defined in the master page?

Was it helpful?

Solution 2

The ContentPlaceHolderID describes the ContentPlaceHolder in the master page where the content will be placed.

Here is the MSDN Documentation

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.content.contentplaceholderid(v=vs.110).aspx

Say you have multiple content placeholders in your master page. You can tell each of your content controls on your page where to place the content. These Content controls do not need to be in the order they appear in your master page.

Hope this helps.

OTHER TIPS

That Content tag corresponds to a ContentPlaceHolder tag in the master page. It would have the id that the ContentPlaceHolderID property specifies, so it would look something like this:

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

The content of the Content tag will be inserted where ContentPlaceHolder tag is in the master page when the page is rendered.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top