Programmatically set the Page Description and Keywords in Asp.Net 4.0


One of the small but new features in Asp.Net 4.0 is the addition of the Title, Metakeyword and Metadescription property in the page class itself. Now we can easily set the Title, Metakeyword and Metadescription (very important for sites looking for SEO.) from the page itself.

This makes adding these values based on some condition or from database very easy. To Add these value to the page now (Asp.Net 4.0) we can write following code.

this.Page.Title = "Fenil Desai Blog";
this.Page.MetaKeywords = "ASP.NET, SQL, Sharepoint, dotnet";
this.Page.MetaDescription = "Some description of My blog";

If we already have some static tag value in the page markup then that will be replaced with the new content provided.

Posted via email from fenildesai's posterous