Thursday, May 15, 2008

Tag – you’re it!

I was putting together an ASP.net page that was retrieving information from a database. This page is going to be indexed by SharePoint. So to make sure that the search experience could be as good as possible, I wanted to make sure that the page includes useful metadata tags.

While trying to figure out the best way of setting the metadata, I came across the HtmlMeta class. This allows you to programmatically add your meta tags to your content:


HtmlMeta metaTag = new
HtmlMeta();


HtmlHead head = (HtmlHead)Page.Header;

metaTag.Name = "DC.Title";

metaTag.Content = "Tag – you're it";

head.Controls.Add(metaTag);


 

Neat, huh?