Error In setting Master Page Header Info

A

Asif

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
 
G

Guest

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);
 

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

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top