Skip to main content

Posts

Showing posts from June, 2011

INSERT KEYWORDS AND DESCRIPTION INTO A PAGE PROGRAMMATICALLY

In other to build the right asp.net site, there is always a need to inject keywords and description for search engines to crawl. So to do that quickly... Of course, the simplest way to add these tags is manually to the HTML part of your ASP.NET page like this: System.Web.UI.HtmlControls.HtmlMeta mKeywords = new System.Web.UI.HtmlControls.HtmlMeta(); mKeywords.Name = "MyKeywords"; mKeywords.Content = "meta1, meta2, meta3"; Page.Header.Controls.AddAt(1, mKeywords); System.Web.UI.HtmlControls.HtmlMeta mDescription = new System.Web.UI.HtmlControls.HtmlMeta(); metaDescription.Content = "This page does a lot"; mDescription.Name = "MyPage"; Page.Header.Controls.AddAt(1, mDescription); In other to create a page in ASP.NET in the latest framework: Page.mDescription = "this is my description."; Page.mKeywords = "key1, key2, key3"; What about assets include, HtmlLink mlink = new HtmlLink(); mlink.Href = relativePath; mlink.Attr...