Monday 21 January 2008

Adding Meta Tags Programmatically

Here's how to add keywords, description, title to an aspx page in the code behind.

Dim h As HtmlHead = DirectCast(Me.Page.Header, HtmlHead)
Dim author As New HtmlMeta
author.Name = "author"
author.Content = "title of website"
Dim d As New HtmlMeta
d.Name = "description"
d.Content = "I am page description"
Dim t As New HtmlMeta
t.Name = "title"
t.Content = "I am page title"

Dim k As New HtmlMeta
k.Name = "keywords"
k.Content = "I am kewords list, etc, etc"
h.Controls.Add(author)
h.Controls.Add(d)
h.Controls.Add(t)
h.Controls.Add(k)

No comments: