asp.net 2.0 master pages

J

Jon Spivey

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/r...nvs05/html/masterpages.asp#masterpages_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
 
S

S. Justin Gengo [MCP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top