Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




How to put meta tags in content pages in asp.net

For SEO purpose meta tags are very important. If we are using master pages then we need to add meta tag on content pages one by one. To add meta tag on content page, we need to add below code on page load.

protected void Page_Load(object sender, EventArgs e) {
Page.Title = "Title of page";
HtmlMeta tag = new HtmlMeta(); tag.Name = "description"; tag.Content = "description of page"; Header.Controls.Add(tag);

HtmlMeta tagKeyword = new HtmlMeta(); tagKeyword.Name = "keywords"; tagKeyword.Content = "keywords of page"; Header.Controls.Add(tagKeyword ); }

If we want to same meta keyword, meta description in all pages of a master page, then we will enter same in all master page.

We can enter that in html section after title tag and before closing of title tag:

<metaname="Description" content="description of page" />

<metaname="Keywords" content="keywords of page" />

P.S: Master page of content file can be seen in html of content page. In page tag,  MasterPageFile


Share this article   |    Print    |    Article read by 25462 times
Author:
Rohit kakria
I am software developer
Related Articles:
Related Interview Questions: