By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,467 Members | 1,308 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,467 IT Pros & Developers. It's quick & easy.

asp.net 2.0 master pages

P: n/a
Hi,
Using VS 2005/VB.net. I need to add a meta description tag and change a
stylesheet link from a page based on a master page. Found this article
http://msdn.microsoft.com/asp.net/re...erpages_topic8
Which seems to suggest it's possible (Listing 11 half way down the page) but
the method for adding a meta tag
Master.Page.Header.Metadata.Add("Description", "blah,blah")
doesn't appear to be recognised by vs and no mention is made of how to
change a stylesheet link. How would this be done?

Thanks very much,
Jon

Jan 27 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Jon,

I believe they are referencing the master page by adding the MasterType
attribute to the page consuming it. After doing so the master page may be
referenced from the consuming page via "Master".

Add this to your .aspx page (just below the page declaration):

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="Auction.aspx.vb" Inherits="Auction"
title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>
And here's an excerpt from an article about it:

Accessing a Master Page from Code
In addition to overriding content, it is possible for a Content Page to
programmatically access its Master Page. A Content Page creates a
strongly-typed reference to the Master Page using the <%@ MasterType %>
directive, specifying the virtual path to the master page:

<%@ MasterType VirtualPath="Site.master" %>

The Content Page can then reference the Master Page using the Master
property of the Page class:

C#
Master.FooterText = "This is a custom footer";
AdRotator ad = (AdRotator)Master.FindControl("MyAdRotator");

VB
Master.FooterText = "This is a custom footer"
Dim ad As AdRotator = Master.FindControl("MyAdRotator")

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Jon Spivey" <jo**@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,
Using VS 2005/VB.net. I need to add a meta description tag and change a
stylesheet link from a page based on a master page. Found this article
http://msdn.microsoft.com/asp.net/re...erpages_topic8
Which seems to suggest it's possible (Listing 11 half way down the page)
but the method for adding a meta tag
Master.Page.Header.Metadata.Add("Description", "blah,blah")
doesn't appear to be recognised by vs and no mention is made of how to
change a stylesheet link. How would this be done?

Thanks very much,
Jon

Jan 27 '06 #2

P: n/a
Thanks very much Justin. This solved the issue.

Cheers,
Jon

"S. Justin Gengo [MCP]" <justin@[no_spam_please]aboutfortunate.com> wrote in
message news:%2***************@TK2MSFTNGP11.phx.gbl...
Jon,

I believe they are referencing the master page by adding the MasterType
attribute to the page consuming it. After doing so the master page may be
referenced from the consuming page via "Master".

Add this to your .aspx page (just below the page declaration):

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="Auction.aspx.vb" Inherits="Auction"
title="Untitled Page" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>
And here's an excerpt from an article about it:

Accessing a Master Page from Code
In addition to overriding content, it is possible for a Content Page to
programmatically access its Master Page. A Content Page creates a
strongly-typed reference to the Master Page using the <%@ MasterType %>
directive, specifying the virtual path to the master page:

<%@ MasterType VirtualPath="Site.master" %>

The Content Page can then reference the Master Page using the Master
property of the Page class:

C#
Master.FooterText = "This is a custom footer";
AdRotator ad = (AdRotator)Master.FindControl("MyAdRotator");

VB
Master.FooterText = "This is a custom footer"
Dim ad As AdRotator = Master.FindControl("MyAdRotator")

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Jon Spivey" <jo**@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Hi,
Using VS 2005/VB.net. I need to add a meta description tag and change a
stylesheet link from a page based on a master page. Found this article
http://msdn.microsoft.com/asp.net/re...erpages_topic8
Which seems to suggest it's possible (Listing 11 half way down the page)
but the method for adding a meta tag
Master.Page.Header.Metadata.Add("Description", "blah,blah")
doesn't appear to be recognised by vs and no mention is made of how to
change a stylesheet link. How would this be done?

Thanks very much,
Jon


Jan 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.