RSS link icon

ASP.net Making dynamic meta tags 

 

I have been making a couple of new web sites lately, and one of my small hobbies is to make programming as easy and small as possible. I always prefer 1 simple line of code instead of 10 complex lines of messy code.

 

asp.net meta tags generator

 

So this time I have tried to make yet another thing easier, now you can implement dynamic meta tags to all of your asp.net pages with just one line of code, after you have imported my class file, you can either download it at the bottom of this page, or analyze and rewrite my asp.net code below.

 

The cool thing about this is that now you do not need to write all those meta tags in the header part of every single one of your pages.

 

Here is the thing. Just write the following line in the page load event of your asp.net page.

metatags.add("PUT IN YOUR PAGE TITLE HERE", "YOUR DESCRIPTION HERE", "KEYWORDS, GOES, HERE")

Now you can extract information from a database, xml or rss feeds and dynamically insert it into the line above in either the description, title or keywords field.

 

The code were are calling with the class file meta tags is here and can also be downloaded at the bottom and is easy to import to your asp.net project.

Public Shared Sub add(ByVal title As String, ByVal description_ As String, ByVal keywords_ As String)
    Dim description As New HtmlMeta
    Dim keywords As New HtmlMeta
        page.Header.Controls.Add(keywords)
        page.Header.Controls.Add(description)
        page.title = title
        keywords.Name = "keywords"
        description.Name = "description"
        description.Content = description_
        keywords.Content = keywords_
End Sub

 

Download the asp.net class file to generate meta tags dynamic here.

Download button


master page problem says: Tuesday, September 16, 2008

I am adding programmatically meta tags as you have provided but these do not works with master pageChr(34)s child pages.

Thanks


Perma says: Friday, June 27, 2008

How about doing this Fortran

Jokes. Thanks for the quick fix


Admin Bob says: Monday, June 23, 2008

Hi Ed, asp and javascript is two different languages, but both client side scripts, this function wont work like that, sorry


Ed says: Wednesday, June 18, 2008

How about ASP javascript please


Scot says: Tuesday, May 27, 2008

How about doing this VBScript


Medivh says: Wednesday, January 23, 2008

How to do it by c#


Admin Bob says: Saturday, January 05, 2008

Hi Mike, I have made a new solution for this, you can download it under the article.


Mike says: Saturday, January 05, 2008

IChr(34)m new to .net so forgive the dumb question. But can you demonstate the page load event code... i created a page and opened up the codebehind fle and tried to refrence the class, but kept seeing squiglly lines under the code indicating improper syntax.

Any help would be greatly appreciated.

Thanks


Brian says: Monday, November 26, 2007

You need to create a reference before using this code. (Meta Tags are a nonshared member)

   


 

 

 

 4

 
 
   Web Premium
 
 

All rights reserved, Copyright 2008. Contact