Personal Blog of Mustafa Basgun

Update Title and Meta Tags Dynamically in ASP.NET

with 3 comments

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.


Written by Mustafa Basgun

April 30, 2008 at 8:00 AM

Posted in ASP.NET, C#, SEO, Web Development

3 Responses

Subscribe to comments with RSS.

  1. 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”;

    //Find code
    metaKeywords = (HtmlMeta)Page.Header.FindControl(“cntrlMetaKeywords”);
    metaKeywords.Content = strNEWKeywords;


    Ryan Bell

    June 12, 2008 at 1:16 PM

  2. 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?


    August 29, 2008 at 9:57 AM

  3. Could we do this with PHP? I do some AJAX calls and I would like to upgrade my META tags.


    September 8, 2008 at 10:19 AM

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: