What does ContentPlaceHolderID mean?

user22707 picture user22707 · Jan 3, 2014 · Viewed 8.2k times · Source

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?

Answer

Guffa picture Guffa · Jan 3, 2014

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.