By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,969 Members | 2,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,969 IT Pros & Developers. It's quick & easy.

Specifying masterpage in web.config?

P: n/a
Hi,

WHen I specify my master page in the page's @Page directive, no problems.
However, when I put it ias an attribute in Web.config's page element, the
designer fails. It just says "Error Creating Control - Content. Content
controsl can only be used in a content page." I know that there's an issue w/
nested masters, but I'm only trying to use one. Interestingly, if I run the
site, it builds and displays properly despite this error. Any thoughts on
this?

-Ben
Dec 23 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Forgot to mention: This is with VS2005 SP1.

-Ben

"Ben R." wrote:
Hi,

WHen I specify my master page in the page's @Page directive, no problems.
However, when I put it ias an attribute in Web.config's page element, the
designer fails. It just says "Error Creating Control - Content. Content
controsl can only be used in a content page." I know that there's an issue w/
nested masters, but I'm only trying to use one. Interestingly, if I run the
site, it builds and displays properly despite this error. Any thoughts on
this?

-Ben
Dec 23 '06 #2

P: n/a
Hi Ben,

Can you show us how you specify the pages element in web.config? I have a
test project and its web.config is like:

<pages masterPageFile ="~/MasterPage.master" ></pages>
And the content page are:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

</asp:Content>
And the 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="form1" runat="server">

<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>

</div>
</form>
</body>
</html>

It seems this work well on my side, is there any difference from your
application?

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 25 '06 #3

P: n/a
Hi Luke,

That's odd. The only difference I spotted was that I was using VB.NET, but I
tried again with C# and got the same result.

Here is the relevant section of my web.config:

<system.web>
<pages masterPageFile="~\MasterPage.master"></pages>

And MasterPage.master:

<%@ 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="form1" runat="server">
<div>
Nav<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
Nav</div>
</form>
</body>
</html>
And Default2.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
Test
</asp:Content>

As I stated, when I hit F5, the page displays properly in the browser as
expected with the master page, but in the VS IDE when I'm in design mide, I
get:

Error 1 Content:Content controls can only be used in a content
page. C:\Users\Ben\Desktop\WebSite1\Default2.aspx C:\...\WebSite1\

Can you confirm that you can work in the page in design view and not only
source view?

Thanks for your help...

-Ben

"Luke Zhang [MSFT]" wrote:
Hi Ben,

Can you show us how you specify the pages element in web.config? I have a
test project and its web.config is like:

<pages masterPageFile ="~/MasterPage.master" ></pages>
And the content page are:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs"
Inherits="Default2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

</asp:Content>
And the 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="form1" runat="server">

<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>

</div>
</form>
</body>
</html>

It seems this work well on my side, is there any difference from your
application?

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 26 '06 #4

P: n/a
Hi Ben,

All work fine on my side with same code. Have you installed VS 2005 sp1? Or
have you tried this in a new project?

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 28 '06 #5

P: n/a
Yes, it only have limited support for master page. But for some simple
master page like the sample I can provide, it suppose to work yet. Did it
still said: "Error Creating Control - Content. Content controsl can only
be used in a content page." ?

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 29 '06 #6

P: n/a
Hello,

This may depends on the actual enviroment, for example, the software and
add-ins installed with VS.NET. So we had better not rely on the design-time
editing for master page.

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 5 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.