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


Kapil says: 2010-02-23

hi i want to extract metatag keyword content  of another website in asp.net
plz tell me at ur earliest
my mail id kapilsoni88@gmail.com
tnks in avance

master page problem says: 2008-09-16

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: 2008-06-27

How about doing this Fortran Jokes. Thanks for the quick fix

Ed says: 2008-06-18

How about ASP javascript please

Admin Bob says: 2008-06-23

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

Scot says: 2008-05-27

How about doing this VBScript

Brian says: 2007-11-26

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

Medivh says: 2008-01-23

How to do it by c#

Mike says: 2008-01-05

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

Admin Bob says: 2008-01-05

Hi Mike, I have made a new solution for this, you can download it under the article.
make money with photoshop - book