Groups | Blog | Home
all groups > asp.net > august 2007 >

asp.net : asp.net master page question


mr t
8/26/2007 7:43:29 PM
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.
Mark Rae [MVP]
8/27/2007 12:00:00 AM
[quoted text, click to view]

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?sourceid=navclient&hl=en-GB&ie=UTF-8&rlz=1T4GGIH_en-GBGB220GB220&q=%22Content+controls+have+to+be+top%2dlevel+controls+in+a+content+page%22

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


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Ladislav Mrnka
8/27/2007 1:28:01 AM
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


[quoted text, click to view]
mr t
8/27/2007 11:01:58 AM
Thank you all. that was easy.
AddThis Social Bookmark Button