Test your technical skills online, appear in Virtual Interview and be ready for job!
Twitter Twitter LinkedIn YouTube Google
Be Interview ready ! | Search
Make friends on DotNetFunda.com and expand your network!
Winners

Win Prizes

Announcements
Like us on Facebook
Sponsor
Top Forums Author
Wed, 23-Apr-2014 Authors
Allemahesh
10
Brierust
10
Klbaiju
10
All Time Authors
Jayakumars
3930
Karthikanbarasan
3455
Chvrsri
3140

Latest members | More ...


(Statistics delayed by 5 minutes)

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 Resolution on 2/18/2011 10:16:21 AM | Points: 10 | Views : 7604 | 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
The Founder
http://www.dotnetfunda.com


Reply | Reply with Attachment

=> Scroll below for responses


Comments or Responses


Login to post response.

Comments / Responses
Select text & click toolbar to format. Formatting appears in viewmode only. HTML Tags are not allowed.
Bold Italic Underline Paragraph Title Code  Link 
 Wait ... Processing ..... please wait.

Found interesting? Add this to: