Solved

nested master pages help

Posted on 2006-07-23
2
250 Views
Last Modified: 2012-06-21
I'm using nested master pages and I need to override the header content so that I can reference a different style sheet for my nested master page, as well as, change the title for my content pages.  I was trying an object oriented approach.

Here is the header section of my main master page:

<%@ Master Language="C#" %>
<%@ Register Src="../UserControls/TopNavigationBar.ascx" TagName="TopNavigationBar"
    TagPrefix="uc2" %>
<%@ Register Src="../UserControls/searchform.ascx" TagName="searchform" TagPrefix="uc1" %>
<%@ Register Src="../UserControls/MainNavigationBar.ascx" TagName="MainNavigationBar" TagPrefix="uc3" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title><% = m_HtmlTitle %></title>
    <link href="../<% = m_HtmlStyles %>" rel="stylesheet" type="text/css" />
</head>
<body>
etc., etc...

Here is tMain master code-behind:

public partial class Template : System.Web.UI.MasterPage
{
    protected String m_HtmlTitle;

        public String HtmlTitle
        {
            get { return m_HtmlTitle; }
            set { m_HtmlTitle = value; }
        }

        protected String m_HtmlStyles;

        public String HtmlStyles
        {
            get { return m_HtmlStyles; }
            set { m_HtmlStyles = value; }
        }

    protected void Page_Load(object sender, EventArgs e)
    {
             this.Master.HtmlTitle = "Educational Software Solutions - Student, Curriculum Assessment & Management :: CompassLearning";
             this.Master.HtmlStyles = "styles.css";
    }
}


I'm getting the following error:

The name 'm_HtmlTitle' does not exist in the current context

Any help is appreciated.


0
Comment
Question by:-Dman100-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 7

Accepted Solution

by:
pradeepsudharsan earned 500 total points
ID: 17166177
0
 

Author Comment

by:-Dman100-
ID: 17168659
I read the articles and tried using:

public partial class index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Master.FindControl("MainNavigationBar1").Visible = false;

        HtmlLink cssLink = new HtmlLink();
        cssLink.Href = "~/styles2.css";
        cssLink.Attributes.Add("rel", "stylesheet");
        cssLink.Attributes.Add("type", "text/css");
        Header.Controls.Add(cssLink);
    }
}

When I ran my page, it showed that the stylesheet had been added, but I still had my original stylesheet listed.  So, my page had my original stylesheet from my master page and the new stylesheet added on the pageload.

I want to replace the stylesheet from the master page with the new one?

Since I have nested master pages, ideally, I'd like to switch the stylesheet within the nested master page.

My master page uses styles.css
My nested master page needs to use styles2.css

Possible?
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question