Introduction
Meta Description and Meta keywords play a major role in terms of making web page search engine friendly. search engine always looks for meta description and meta keywords from the page contents. Here I m showing how to set meta description and meta keywords in web page.
ASP.Net 4.0 provided new two properties at page level for setting meta description and meta keywords.we can add these two properties with page class in Code behind or in Page Directives.
Asp.Net 4.0
C#.Net
VB.net
Earlier Version of Asp.Net
Need to create some function which will set meta description and meta keywords. here it use HtmlMeta to do the same.
C#.Net
VB.Net
Meta Description and Meta keywords play a major role in terms of making web page search engine friendly. search engine always looks for meta description and meta keywords from the page contents. Here I m showing how to set meta description and meta keywords in web page.
ASP.Net 4.0 provided new two properties at page level for setting meta description and meta keywords.we can add these two properties with page class in Code behind or in Page Directives.
Asp.Net 4.0
C#.Net
protected void Page_Load(object sender, EventArgs e) { Page.MetaKeywords = "Test Page"; Page.MetaDescription = "Test Page"; }
VB.net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.Page.MetaKeywords = "Test Page" Me.Page.MetaDescription = "Test Page" End Sub
Earlier Version of Asp.Net
Need to create some function which will set meta description and meta keywords. here it use HtmlMeta to do the same.
C#.Net
protected void Page_Load(object sender, System.EventArgs e) { SetMetaDescription(this.Page, "Test Page"); SetMetaKeyword(this.Page, "Test Page"); } public void SetMetaDescription(Page PageName, string strMetaDesc) { HtmlMeta metaDesc = new HtmlMeta(); HtmlHead head = PageName.Header; metaDesc.Name = "description"; metaDesc.Content = strMetaDesc; head.Controls.Add(metaDesc); } public void SetMetaKeyword(Page PageName, string strMetaKeyword) { HtmlMeta metaKeys = new HtmlMeta(); HtmlHead head = PageName.Header; metaKeys.Name = "keyword"; metaKeys.Content = strMetaKeyword; head.Controls.Add(metaKeys); }
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load SetMetaDescription(Me.Page, "Test Page") SetMetaKeyword(Me.Page, "Test Page") End Sub Public Sub SetMetaDescription(ByVal PageName As Page, ByVal strMetaDesc As String) Dim metaDesc As New HtmlMeta() Dim head As HtmlHead = PageName.Header metaDesc.Name = "description" metaDesc.Content = strMetaDesc head.Controls.Add(metaDesc) End Sub Public Sub SetMetaKeyword(ByVal PageName As Page, ByVal strMetaKeyword As String) Dim metaKeys As New HtmlMeta() Dim head As HtmlHead = PageName.Header metaKeys.Name = "keyword" metaKeys.Content = strMetaKeyword head.Controls.Add(metaKeys) End SubI hope this article was useful and I thank you for viewing it. keep visiting blog , you can get more stuff.
No comments:
Post a Comment