Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Master page content no showing in derived .aspx pages

Status
Not open for further replies.

MeonR

Programmer
Aug 16, 2002
97
US
Hello all:

I am using VS2005 pro, and, I have a single master page with some derived content pages. The content in the master page is not showing up in any of the derived content pages. Has anyone out there had this problem, and what was the fix?

Thanks
MeonR

"The beatings will continue until morale improves
 
Thanks here is the code. Its now throwing the following exception as well..

Thanks
MeonR

Server Error in '/PresbyterianChurch' Application.
--------------------------------------------------------------------------------

Cannot find ContentPlaceHolder 'ContentPlaceHolder1' in the master page '/PresbyterianChurch/MasterPage.master', verify content control's ContentPlaceHolderID attribute in the content page.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Cannot find ContentPlaceHolder 'ContentPlaceHolder1' in the master page '/PresbyterianChurch/MasterPage.master', verify content control's ContentPlaceHolderID attribute in the content page.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[HttpException (0x80004005): Cannot find ContentPlaceHolder 'ContentPlaceHolder1' in the master page '/PresbyterianChurch/MasterPage.master', verify content control's ContentPlaceHolderID attribute in the content page.]
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +8668567
System.Web.UI.Page.get_Master() +51
System.Web.UI.Page.ApplyMasterPage() +15
System.Web.UI.Page.PerformPreInit() +45
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +282




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3082


%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<head runat="server">
<title>master</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:contentplaceholder id="cp1" runat="server">
<asp:Menu ID="Menu1" runat="server" BackColor="#B5C7DE" DynamicHorizontalOffset="2"
Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284E98" StaticSubMenuIndent="10px"
Style="left: 271px; position: absolute; top: 0px; z-index: 100;" Orientation="Horizontal">
<StaticSelectedStyle BackColor="#507CD1" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicHoverStyle BackColor="#284E98" ForeColor="White" />
<DynamicMenuStyle BackColor="#B5C7DE" />
<DynamicSelectedStyle BackColor="#507CD1" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticHoverStyle BackColor="#284E98" ForeColor="White" />
</asp:Menu>
<asp:Image ID="Image1" runat="server" ImageUrl="~/ARCHITECTURE 0217.png" Style="z-index: 102;
left: 262px; position: absolute; top: 55px" />

</asp:contentplaceholder>
</div>
</form>
</body>
</html>

//Derived Page code

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
</asp:Content>


"The beatings will continue until morale improves
 
Cannot find ContentPlaceHolder 'ContentPlaceHolder1' in the master page
As the error says, your Content Page is looking for a ContentPlaceHolder named "ContentPlaceHolder1":
Code:
<asp:Content ID="Content1" ContentPlaceHolderID="[!]ContentPlaceHolder1[/!]" Runat="Server">
but your master page only has a ContentPlaceHolder named "cp1":
Code:
<asp:contentplaceholder id="[!]cp1[/!]" runat="server">

Mark,

Darlington Web Design
Experts, Information, Ideas & Knowledge
ASP.NET Tips & Tricks
 
Thanks Mark,

That worked, manually changing the id of the contentplaceholder did it, odd, changes use to show up automatically.

Thanks
MeonR


"The beatings will continue until morale improves
 
I spoke to soon. Now it won't let me add anything to the derived page. the content place holder on the derived page now just says master. and will not let any controls be added?

Thanks
MeonR

"The beatings will continue until morale improves
 
If you mean that you can't drag and drop any controls via the design window in the IDE then I'm not sure what the issue is, I always use the HTML view and write out any controls I need so that I have 100% control over what is rendered to the final page.

Mark,

Darlington Web Design
Experts, Information, Ideas & Knowledge
ASP.NET Tips & Tricks
 
That's pretty much it. Its like the master and the derived page are locked together and I can edit the master but nothing else. the html view does not even appear when on the derived page. I am wondering if this is not a case of some @$%^*( update from MS screwing things up??

Thanks
MeonR

"The beatings will continue until morale improves
 
There's no update issue. I haven't heard of this problem before. If you can, I would just create another project from scratch and try again. There may be something corrupt in the project for soulution.
 
Thanks All

I created another project as you suggested, same problem, its like the master and derived pages are locked together and I can only edit the master page. I also went to another project I had and did the same thing, worked fine?!?! Any ideas?

Thanks
MeonR

"The beatings will continue until morale improves
 
Thanks... I also noted that the contentplaceholder on the derived page is in design view showing Content - Content1(Master) instead of custom as it usually does.

Here is the code

//Master
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
<asp:Menu ID="Menu1" runat="server" Height="51px" Orientation="Horizontal" Style="z-index: 100;
left: 279px; position: absolute; top: 0px" Width="455px">
</asp:Menu>
</asp:contentplaceholder>
</div>
</form>
</body>
</html>


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>

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


"The beatings will continue until morale improves
 
Thanks:

Ok, I manually added the asp:content control but its still not picking up the content from the master page. Something else is going on.

"The beatings will continue until morale improves
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top