suzannea595
Technical User
Hi,
I'm trying to set up nested Master Pages and am having difficulties. I am very, very new to Visual Studio and ASP.NET so any help is appreciated.
I am trying to set up default.aspx with a Master Page called omfnMaster.master. I have a second page, default2.aspx, which has a master page of espanolMaster.master AND omfnMaster.master.
I got this all to work using the sample files I've found online which explain nested Master Pages, but when I changed the names of the files to suit my project, I broke everything.
When I view aspx pages in a browser, I receive this error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).
Source Error:
Line 10: using System.Web.UI.HtmlControls;
Line 11:
Line 12: public partial class MasterPage : System.Web.UI.MasterPage
Line 13: {
Line 14: protected void Page_Load(object sender, EventArgs e)
Source File: d:\My Documents\Visual Studio 2005\WebSites\OMFN Portal 4\omfnMaster.master.cs Line: 12
--------------------------
Here is my code:
TOP MASTER FILE:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="omfnMaster.master.cs" Inherits="omfnMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<head runat="server">
<title>Old Mutual Financial Network</title>
<link href="omfn.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>
SECOND LEVEL MASTER FILE:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="~/espanolMaster.master.cs" Inherits="espanolMaster" MasterPageFile="~/omfnMaster.master" %>
<asp:Content runat="server" ID="Content2"
ContentPlaceHolderID="ContentPlaceHolder1">
<h3>Nested Content</h3>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</asp:Content>
MAIN CONTENT PAGE:
<%@ Page Language="C#" MasterPageFile="~/espanolMaster.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
This is the Portal content page.
<p><a href="Default2.aspx">Español</a>
</p></asp:Content>
SECOND CONTENT PAGE:
<%@ Page Language="C#" MasterPageFile="~/espanolMaster.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
This is the Content page for En Español
<p>Hola!</p>
<p><a href="default.aspx">OMFN Portal</a></p>
</asp:Content>
-----------------
Thanks so much for any help,
S
I'm trying to set up nested Master Pages and am having difficulties. I am very, very new to Visual Studio and ASP.NET so any help is appreciated.
I am trying to set up default.aspx with a Master Page called omfnMaster.master. I have a second page, default2.aspx, which has a master page of espanolMaster.master AND omfnMaster.master.
I got this all to work using the sample files I've found online which explain nested Master Pages, but when I changed the names of the files to suit my project, I broke everything.
When I view aspx pages in a browser, I receive this error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).
Source Error:
Line 10: using System.Web.UI.HtmlControls;
Line 11:
Line 12: public partial class MasterPage : System.Web.UI.MasterPage
Line 13: {
Line 14: protected void Page_Load(object sender, EventArgs e)
Source File: d:\My Documents\Visual Studio 2005\WebSites\OMFN Portal 4\omfnMaster.master.cs Line: 12
--------------------------
Here is my code:
TOP MASTER FILE:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="omfnMaster.master.cs" Inherits="omfnMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
<html xmlns=" >
<head runat="server">
<title>Old Mutual Financial Network</title>
<link href="omfn.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>
SECOND LEVEL MASTER FILE:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="~/espanolMaster.master.cs" Inherits="espanolMaster" MasterPageFile="~/omfnMaster.master" %>
<asp:Content runat="server" ID="Content2"
ContentPlaceHolderID="ContentPlaceHolder1">
<h3>Nested Content</h3>
<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</asp:Content>
MAIN CONTENT PAGE:
<%@ Page Language="C#" MasterPageFile="~/espanolMaster.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
This is the Portal content page.
<p><a href="Default2.aspx">Español</a>
</p></asp:Content>
SECOND CONTENT PAGE:
<%@ Page Language="C#" MasterPageFile="~/espanolMaster.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
This is the Content page for En Español
<p>Hola!</p>
<p><a href="default.aspx">OMFN Portal</a></p>
</asp:Content>
-----------------
Thanks so much for any help,
S