Solved

nested master pages help

Posted on 2006-07-23
2
241 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-
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

759 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now