Update Title and Meta Tags Dynamically in ASP.NET
If you are using master pages, updating your title or meta tags (such as “description” and “keywords”) may become an important subject because of the SEO purposes. Since there are several ways to accomplish this, here is my way in C# to do so.

Instead of looping through to remove all meta tags and re-adding them, you can just set the ID of the tag when you create it and use the FindControl method with your specified ID to locate the specific meta tag that you want to modify.
//Creation code
metaKeywords = new HtmlMeta();
metaKeywords.Name = “keywords”;
metaKeywords.Content = strKeywords;
metaKeywords.ID = “cntrlMetaKeywords”;
this.Page.Header.Controls.Add(metaKeywords);
//Find code
metaKeywords = (HtmlMeta)Page.Header.FindControl(“cntrlMetaKeywords”);
metaKeywords.Content = strNEWKeywords;
Ryan
http://www.newsorviews.com
Ryan Bell
June 12, 2008 at 1:16 PM
This is cool, but I am still using ASP.NET 1.1 and the code does not work. How is the solution for 1.1?
Cez
August 29, 2008 at 9:57 AM
Could we do this with PHP? I do some AJAX calls and I would like to upgrade my META tags.
Pedram
September 8, 2008 at 10:19 AM