Programmatically Adding Markup to the <head> Region
The head ContentPlaceHolder allows us to declaratively add custom markup to the master page's <head> region. Custom markup may also be added programmatically. Recall that the Page class's Header property returns the HtmlHead instance defined in the master page (the <head runat="server">).
Being able to programmatically add content to the <head> region is useful when the content to add is dynamic. Perhaps it's based on the user visiting the page; maybe it's being pulled from a database. Regardless of the reason, you can add content to the HtmlHead by adding controls to its Controls collection like so.
// Programmatically add a <meta> element to the Header
HtmlMeta keywords = new HtmlMeta();
keywords.Name = "keywords";
keywords.Content="master page,asp.net,tutorial";
Page.Header.Controls.Add(keywords);
The above code adds the <meta> keywords element to the <head> region, which provides a comma-delimited list of keywords that describe the page. Note that to add a <meta> tag you create an HtmlMeta instance, set its Name and Content properties, and then add it to the Header's Controls collection. Similarly, to programmatically add a <link> element, create an HtmlLink object, set its properties, and then add it to the Header's Controls collection.
// Programmatically add a <meta> element to the Header
HtmlMeta keywords = new HtmlMeta();
keywords.Name = "keywords";
keywords.Content="master page,asp.net,tutorial";
Page.Header.Controls.Add(keywords);
The above code adds the <meta> keywords element to the <head> region, which provides a comma-delimited list of keywords that describe the page. Note that to add a <meta> tag you create an HtmlMeta instance, set its Name and Content properties, and then add it to the Header's Controls collection. Similarly, to programmatically add a <link> element, create an HtmlLink object, set its properties, and then add it to the Header's Controls collection.
Note: To add arbitrary markup, create a LiteralControl instance, set its Text property, and then add it to the Header's Controls collection.
Note: To add arbitrary markup, create a LiteralControl instance, set its Text property, and then add it to the Header's Controls collection
Note: To add arbitrary markup, create a LiteralControl instance, set its Text property, and then add it to the Header's Controls collection
so will it create any extra impact on search engine, means just like we add these tags normally is it improves the rank.
ReplyDeleteThanks for sharing nice information with us. i like your post and all you share with us is uptodate and quite informative, i would like to bookmark the page so i can come here again to read you, as you have done a wonderful job.
ReplyDeletehow to get fb page likes
The web site is lovingly serviced and saved as much as date. So it should be, thanks for sharing this with us.
ReplyDeleteget 1000 likes on facebook photo 2014