asp.net master page question

  • Thread starter Thread starter mr t
  • Start date Start date
M

mr t

For those of you whose first language is English, could you please
explain to me what this means?

"Content controls have to be top-level controls in a content page or a
nested master page that references a master page"

that's the error I got from visual studio 2005 when trying to run a
page which has a master page. Is it my english or people in Redmond,
WA are faring poorly on English 101.

thanks in advance.
 
Hi,
this error says you have to place all content in your content page has to be
placed to asp:Content control(s). Number of these asp:Content controls cannot
be greater than placeholders in master page.

So in example:
Master page
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="myForm" runat="server">
<div>
<asp:contentplaceholder id="FirstPlacelholder" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>

Content page
<%@ Page Language="C#" AutoEventWireup="true"
MasterPageFile="~/MasterPage.master" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

<asp:Content runat="server" ID="myContent"
ContentPlaceHolderID="FirstPlacelholder">
<!-- put all content here, if any content is placed outside of this
element you will get your error -->
</asp:Content>

Regards,
Ladislav
 
For those of you whose first language is English, could you please
explain to me what this means?

"Content controls have to be top-level controls in a content page or a
nested master page that references a master page"

Three possible reasons:

1) Your content page doesn't have a correct reference to its MasterPage in
the @Page directive

2) You've forgotten to specify runat="server" in your <asp:Content /> tag

3) You have placed content outside the <asp:Content>....</asp:Content>
section

http://www.google.co.uk/search?sour...e+to+be+top-level+controls+in+a+content+page"

If none of the above fixes it, please provide the full markup of your
content page.
 
Back
Top