Search code examples
asp.netvb.netvisual-studio-2008headermeta-tags

How to add Meta Tags dynamically to pages?


I have a website with product pages that are created dynamically depending on the itemws in my database. The site works fine with no errors. I now would like to add Meta Tags to the header.

When the pages are created I would like to dynamically/programmically set the meta tags for that page - Keywords, etc.

How can I add them using VB.Net in Visual Studio 2008. I am using a masterpage for the overall layout if that affects anything.


Solution

  • See: http://ryanfarley.com/blog/archive/2006/03/25/18992.aspx I think its exactly what you want ex.

    
    // Render: <meta name="date" content="2006-03-25" scheme="YYYY-MM-DD" />
    meta = new HtmlMeta();
    meta.Name = "date";
    meta.Content = DateTime.Now.ToString("yyyy-MM-dd");
    meta.Scheme = "YYYY-MM-DD";
    this.Header.Controls.Add(meta);