Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does ContentPlaceHolderID mean?

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?

like image 221
user22707 Avatar asked Feb 10 '26 23:02

user22707


2 Answers

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.

like image 65
Nico Avatar answered Feb 12 '26 16:02

Nico


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.

like image 34
Guffa Avatar answered Feb 12 '26 14:02

Guffa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!