Friday, 21 December 2012

Adding Meta Tags Dynamically

Adding Meta Tags Dynamically

The easiest way to add META TAGS to the <head> element of your web page is to add it
declaratively in HTML of your ASP.NET page like this:

     <META name="Description" content="Asp.Net FAQs Home Page.">

But We can add this Programmatically like this -->

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";

        HtmlMeta meta2 = new HtmlMeta();
        meta2.Name = "Keywords";
        meta2.Content = "Asp.Net .NET";

No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top