Home » C#

Dynamically change page title and meta tags in C#

17 January 2009 266 views No Comment Popularity: 3% Share/Bookmark

Change page title and meta tags dynamically/programmatically in C#.net

to change page title

Page.Title = “New Page Title”;

to change meta tags

// Create instances of an HtmlMeta control.
HtmlMeta hm1 = new HtmlMeta();
HtmlMeta hm2 = new HtmlMeta();

// Get a reference to the page header element.
HtmlHead head = (HtmlHead)Page.Header;

// Define HTML elements
hm1.Name = “keywords”;
hm1.Content = “keywords of your web page”;
head.Controls.Add(hm1);

hm2.Name = “description”;
hm2.Content = “description of your web page”;
head.Controls.Add(hm2);

From Mukesh Chapagain's Blog | Post Dynamically change page title and meta tags in C#

Related posts:

  1. Magento: Set/Change page layout, title tag, meta keywords and description
  2. What are Meta-Tags? Full Description of Meta tags
  3. Magento: Set title, keywords and description in your module
  4. Page refresh in PHP
  5. jQuery: Print array and object

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.