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

Error In setting Master Page Header Info

P: n/a
Hi All,

I did follow the MSDN article (http://msdn2.microsoft.com/en-us/
library/ms379585(VS.80).aspx
) for overriding Master Page properties by setting page title and
other Meta information( Keyword and Description) for individual
content page by writing the following line on Page_Load event in
content page

Sub Page_Load()
Master.Page.Header.Title = "Content Title"
Master.Page.Header.Metadata.Add("Keywords", "blah,blah")
Master.Page.Header.Metadata.Add("Description", "blah,blah")
End Sub

But it is giving me the following error:
System.Web.UI.HtmlControls.HtmlHead' does not contain a definition for
Metadata

Is there any idea why it is happening as it is clearly written in MSDN
article or any simple workaround for it?

Thanks

Asif

Feb 8 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Feb 8, 8:55 am, "Asif" <asif.im...@gmail.comwrote:
Hi All,

I did follow the MSDN article (http://msdn2.microsoft.com/en-us/
library/ms379585(VS.80).aspx
) for overriding Master Page properties by setting page title and
other Meta information( Keyword and Description) for individual
content page by writing the following line on Page_Load event in
content page

Sub Page_Load()
Master.Page.Header.Title = "Content Title"
Master.Page.Header.Metadata.Add("Keywords", "blah,blah")
Master.Page.Header.Metadata.Add("Description", "blah,blah")
End Sub

But it is giving me the following error:
System.Web.UI.HtmlControls.HtmlHead' does not contain a definition for
Metadata

Is there any idea why it is happening as it is clearly written in MSDN
article or any simple workaround for it?
In Beta 2 Version 2, the Header.Metadata.Add() method was removed from
the framework. This article is out of the date

Check this workaround from http://www.howtoadvice.com/SetMetaTags

//Get the htmlHead your aspx page is using (from the Master page)
//Master page must include the runat server attribute in the head tag:
<head runat="server">
HtmlHead head = (System.Web.UI.HtmlControls.HtmlHead)Header;

//Create a htmlMeta object
HtmlMeta meta = new HtmlMeta();

//Specify meta attributes
meta.Attributes.Add("name", "keywords");
meta.Attributes.Add("content", "keyword1, keyword2, keyword3");

// Add the meta object to the htmlhead's control collection
head.Controls.Add(meta);

Feb 8 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.