Welcome to Dream.In.Code
Become a VB Expert!

Join 149,443 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,219 people online right now. Registration is fast and FREE... Join Now!




Limit dynamic meta description, How to?

 
Reply to this topicStart new topic

Limit dynamic meta description, How to?

darkknight187
23 Nov, 2007 - 09:25 AM
Post #1

New D.I.C Head
*

Joined: 21 Nov, 2007
Posts: 3


My Contributions
In order to make my site more search engine friendly, I have decided to make the meta description pull the listing description and insert it into the meta description.

Here's my code.

CODE
Dim metaDescription As New HtmlMeta
metaDescription.Name = "description"
metaDescription.Content = ad.Description + " This is a test"
Page.Header.Controls.Add(metaDescription)


The only issue I have is that some of the descriptions can be quite long, How can I limit the description so it will only accept so many words???

Thank you in advance,

Daniel
User is offlineProfile CardPM
+Quote Post

darkknight187
RE: Limit Dynamic Meta Description, How To?
23 Nov, 2007 - 02:01 PM
Post #2

New D.I.C Head
*

Joined: 21 Nov, 2007
Posts: 3


My Contributions
Nevermind, I figured it out.

Here's what will do it.

CODE

Dim metaDescription As New HtmlMeta
            Dim MetaCount As Integer = ad.Description.Length

            metaDescription.Name = "description"

            If MetaCount <= 150 Then
                metaDescription.Content = ad.Description
            Else
                metaDescription.Content = ad.Description.ToString().Substring(0, 150)
            End If

            Page.Header.Controls.Add(metaDescription)


Thanks anyway

Daniel Meis

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 12:39PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month