7

I have a website that can be accessed from www.blahblah.com and special.blahblah.com. The www site always works but occasionly I get a 'Content controls have to be top-level controls in a content page or a nested master page that references a master page' error on the special site.

It's exactly the same code running in both situations and the offending page doesn't even have a master page. Why would it work all the time on one and fail sometimes on the other?

horatio
  • 406
  • 1
  • 7
  • 16

6 Answers6

5

If anyone gets this error message when dynamically switching master pages, make sure your code is

MasterPageFile = "TheMasterPage.master"

Not

this.master.MasterPageFile = "TheMasterPage.master"
MGOwen
  • 6,562
  • 13
  • 58
  • 67
4

Just got this problem. It was because we had a tag ending with double slashes:

<//asp:HyperLink>
Daniel Ryan
  • 6,976
  • 5
  • 45
  • 62
3

Look for an unclosed tag in one of your server controls, im running VS2010 and the IDE aspx validator didnt pick up on the unclosed tag

ewitkows
  • 3,528
  • 3
  • 40
  • 62
2

It can also happen if you put a tag on a website, then another one in the middle of that one and you close the second outside the first so they kinda cut themselves if you know what I mean

KMT
  • 21
  • 1
1

My issue was that i mixed up <ASP:CONTENT with <ASP:ContentPlaceholder

<ASP:CONTENT goes on the content file...not the Master pages! Ensure you're using the correct control.

MunsterMan
  • 307
  • 1
  • 8
1

In my case, I was trying to make a RequiredFieldValidator self-closing. The control must have separate ending tag: </asp:RequiredFieldValidator>.

THIS WILL CAUSE THE ERROR: <asp:RequiredFieldValidator ID="rfvx" runat="server"ErrorMessage="*</b>"ControlToValidate="xxx" />

GOOD SYNTAX: <asp:RequiredFieldValidator ID="rfvx" runat="server" ErrorMessage="*</b>"ControlToValidate="xxx" ></asp:RequiredFieldValidator>