Home » C#

Dynamically change page title and meta tags in C#

17 January 2009 9 views No Comment

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

Popularity: 1%

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. Wordpress: Optimizing 404 Page Not Found page
Share/Bookmark
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

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.