Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 19280 |  Welcome, Guest!   Register  Login
 Home > Forums > Error and Resolution > System.Web.HttpException: Content controls have to be top-level controls in ...
SheoNarayan

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

Replies: 0 | Posted by: SheoNarayan on 2/18/2011 | Category: Error and Resolution Forums | Views: 5491 | Status: [Microsoft_MVP] [Administrator] | Points: 10  


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, Microsoft MVP
The Founder
http://www.dotnetfunda.com


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

  No reply found.


Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/19/2013 8:45:35 PM