What does ContentPlaceHolderID mean?

10.4k views Asked by At

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?

2

There are 2 answers

1
Nico On BEST ANSWER

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.

0
Guffa On

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.