Hey Guys,
I've made a couple of web pages and now i want to add a master page to all the pages. But when i tried to add the master page the following error occured
"Content controls have to be top-level controls in a content page or a nested master page that references a master page."

FYI i did not check the check box "Select Master Page" when i was making the pages. Does this make a difference??
Please suggest how i could add master pages to my web pages??

Recommended Answers

All 4 Replies

If you want to add Master Page to your existing web pages, the do the following things:

1. set the MasterPageFile property to your .master file name.
2. Remove the form tage from the child page if the master page already has the form tag.
3. Wrap controls in the child page with a Content control

<asp:Content id="myContent" runat="server" ContentPlaceholderId="MasterID">  page contents</asp:Content>

The value of ContentPlaceHolderID should be the ID of the ContentPlaceHolder control from the master page.

Also check this link: http://asptutorials.net/ASP/masterpages/

Thanks dude..that really helped

If your question is answered, please mark this thread as solved.

try giving out the content page same as that given to the master page id. also see the content page has the master page file directive

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.