Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

nested master pages help

Posted on 2006-07-23
2
Medium Priority
?
251 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 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
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…
Suggested Courses

722 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