<META name="Description" content="Asp.Net FAQs Home Page." That was easy alright. But what if we need to add META TAGS dynamically, for example if we want to add different Keywords meta tags for each page depending on the actual content of the page? There is an easy way to accomplish this thanks to the ASP.NET. All we need to do is to add the following code to our Page_Init method:
protected void Page_Init(object sender, EventArgs e)
{
HtmlMeta meta1 = new HtmlMeta();
meta1.Name = "Description";
meta1.Content = "Page description";
this.Page.Header.Controls.Add(meta1);
HtmlMeta meta2 = new HtmlMeta();
meta2.Name = "Keywords";
meta2.Content = "Asp.Net .NET";
this.Page.Header.Controls.Add(meta2);
}
note: This also works with MasterPages. Just place this code in your content page.
Show Comments (0)
Loading Comments. Please Wait...