Jeremy Wadsworth
My Contribution to the ASP.NET Community


Welcome   
Welcome to my personal website. Here you will find blog posts related to web development as well as personal related interests. If you're here for the source code to my Personal Web Site Kit, please register and you'll receive an email when your account has been approved.


Latest Blog Entries

 Thursday, May 10, 2007


Setting meta tags for content pages in ASP.NET 2.0    
I replied to a post in the forums regarding how to set meta tags for each content page in an app. If you set the meta tags in the master page, all your pages will have the same meta tags. One way to accomplish setting the meta tags for each content page is to use code like the following.

Dim metaTag As New HtmlMeta
Dim HeadTag As HtmlHead = CType(Page.Header, HtmlHead)
metaTag.Attributes.Add("name", "description")
metaTag.Attributes.Add("content", "your description goes here")
HeadTag.Controls.Add(metaTag)
metaTag = New HtmlMeta
metaTag.Attributes.Add("name", "keywords")
metaTag.Attributes.Add("content", "your keyword go here")
HeadTag.Controls.Add(metaTag)


This code could also be used to dynamically add meta tags to your pages. The tag values could be stored in a database, and then retrieved and plugged into the code.


jeremy at 4:41 PM | (9) Comments | Add a comment | Permalink





Commments
storm said...

What if you have an internal site search engine that relies on meta tags? And because it is code, would it be executed whenever a search bot is indexing your site?

Thursday, May 17, 2007 2:28 AM

jeremy said...

I'm not sure about that. I don't know how search bots work. If the search bot actually gets the page, then the code should be executed and the meta tags should be crawled as if they were static. I'm just not sure though.

Tuesday, May 22, 2007 8:10 PM

Robert said...

How can I retrieve the meta tag title value from a field value that is posted on the page from the database? For example, if the detail view that comes up when the page opens, has fields from the database. Can I use the vaues of these fields to fill out the title tab or description? That would be more helfull since the tag values come from the page itself and it is more valuable to the search engines.

Sunday, June 17, 2007 8:40 AM

jeremy said...

You can set the meta tag values from the page_load of each page filling them with values from what ever fields you want from the database.

Monday, July 02, 2007 8:02 PM

John said...

Hi Jeremy, I'm just testing your comments and CAPTCHA. Nice site btw.

Saturday, July 28, 2007 2:24 PM

Robert said...

How can I retrieve the meta tag title value from a field value that is posted on the page from the database? For example, if the detail view that comes up when the page opens, has fields from the database. Can I use the vaues of these fields to fill out the title tab or description? Can you give the code? the database is taxid the table is taxidnumber and the column is ID

Saturday, November 03, 2007 11:28 PM

jeremy said...

Robert, what control is the data being bound to and how is it being bound?

Tuesday, November 06, 2007 11:10 AM

Tiffany jewellery said...

You can set the meta tag values from the page_load of each page filling them with values from what ever fields you want from the database.

Friday, July 16, 2010 9:09 PM

investment in Bristol said...

Monty, the advanceWarning variable is actually the intRedirectTime variable. I renamed the variable and forgot to change it in that line of code. I have corrected the blog post. Thanks.

Saturday, August 28, 2010 2:16 AM

  Leave a comment

Enter Your Name:
 
Enter your website
Security code from image below:  
Need Custom Controls Work or Training?
   


Join WebHost4Life.com






If you would like to help support this project, please click the button below to make a small donation.