Search
Sponsor
Winners

Win Prizes

Social Presence
Twitter Twitter LinkedIn YouTube Google

Like us on Facebook
Advertisements
Top Forums Author
Tue, 30-Sep-2014 Authors
Mandlaa
20
Vinokanna
10
Vishal@Neeraj
10
All Time Authors
Jayakumars
4170
Karthikanbarasan
3455
Chvrsri
3140

Latest members | More ...


(Statistics delayed by 5 minutes)
 Forum Post

System.Web.HttpException: Content controls have to be top-level controls in a content page or a nest

SheoNarayan
Posted by SheoNarayan under Error and Solution on 2/18/2011 10:16:21 AM | Points: 10 | Views : 8967 | Status : [Microsoft_MVP] [Administrator] | Replies : 0


I was getting this error when trying with the Nested Master page.

System.Web.HttpException: Content controls have to be top-level controls in a content page or a nested master page that references a master page.

You need to focus following while dealing with this issue

1. By default Visual Studio doesn't not create ContentPlaceHolder control in the Child Master page, for example look at the below code

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<p>Written in child master page </p>
<asp:ContentPlaceHolder id="ChildMasterContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>

</asp:Content>


You will need to make sure that you are keeping the ContentPlaceHolder control inside the asp:Content control.

2. Any content (plain text/html control/asp.net control) either in the Child master page or Content page must be inside the asp:Content control.

3. You can keep any content in the Maste Master page under body tag.

4. The hierarchy of Page_Load method fires like this
--------------Content page page_load
-------------------Child master page page_load
-------------------------Master master page_load

Hope this helps.

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com


(No response found.)

Login to post response


Found interesting? Add this to: