Pages

Sunday, June 14, 2009

Dynamically Adding Meta Tags in ASP.NET 2.0

The HtmlMeta class is provided to created meta tags dynamically in your page header.

You can easily create a HtmlMeta object and add it to the Controls collection in the HtmlHead class exposed via Page.Header.

Here is the sample:

Custom Adding Title Tag :

Me.Header.Title = "Title Of Page Here"

Custom Adding Meta Tag :
Dim metaDescription As New HtmlMeta()
metaDescription.Name = "description"
metaDescription.Content = "A description of page here."
Me.Header.Controls.Add(metaDescription)

No comments:

Post a Comment