Solved

nested master pages help

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Json and asp.net mvc 2 46
ADO.NET ENTITY DATA MODEL 3 32
Displaying a web form as a modal popup dialog box. 4 25
Regex validation 2 0
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

864 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

18 Experts available now in Live!

Get 1:1 Help Now