Posts

Showing posts with the label SEO

Adding Meta tags to Content pages having a common Master page in ASP.Net 2.0 || Setting Meta tags programatically on an ASP.Net page

The problem: ASP.Net 2.0 introduced master pages which promotes HTML Markup re usability among several Content pages. While working with Content pages I found that you cannot set the Meta tags for the page from the HTML markup. I did some research and found the following solution of setting the meta tags of a page programatically. I hope the solution will be helpful to developers struggling to set Meta tags for content pages and people trying to perform SEO on content pages that use a master page. The solution: As shown below, add the following code inside the Page_Load method of the content page. Please set the Title, Meta Description and Meta Keywords tags to the appropriate .Net string values of your preference. protected void Page_Load( object sender, EventArgs e) { if (!IsPostBack) { //Adding Meta tags to the Content Page ASP.Net 2.0 HtmlHead header = ( HtmlHead )Page.Header; ...