Thursday 25 August 2011

Dynamically add meta tags in ASP.Net

Add the following code to master page on the page_load event handler. All it does is to add a keyword meta tag to the header of the html page from server-side, which opens a door to all other possibilities.

protected void Page_Load(object sender, EventArgs e)
{
   HtmlMeta meta = new HtmlMeta();
   meta.Name = "keywords";
   meta.Content = "ASP.Net, Web, meta tag";
   Header.Controls.Add(meta);
}

No comments:

Post a Comment