Developer forum

Forum » Development » meta description

meta description

Paul Nilsson
Reply
I want tho set the Meta Description if it is empty.

Whith this I can change the text of the description:
pageView.Meta.MetaTags.Remove("Description");
pageView.Meta.MetaTags.Add("Description", "text");
But before I change it I need to know if it's empty.
Where can I see if there is a description?

Replies

 
Paul Nilsson
Reply

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer
Hi Paul,

MetaTags is just a Hashtable and you can check its contents directly. Something like this would work:
string description = String.Empty;
if (PageView.Meta.MetaTags["Description"] != null)
{
  description = PageView.Meta.MetaTags["Description"].ToString();
  if (string.IsNullOrEmpty(description))
  {
    PageView.Meta.MetaTags["Description"] = "Your new value";
  }
}

Hope this helps,

Imar
Votes for this answer: 0
 
Anders Ebdrup
Reply

Hi Imar,

 

Do you know if the property "MetaTags" is still public and avaiable for manipulating the meta tags?

 

Best regards, Anders

 
Mikkel Ricky
Reply

The MetaData property is not public (anymore), but you can use the Add method on PageView.Meta to add metatags:

Public Sub Add(ByVal metatag As String)
Public Sub Add(ByVal name As String, ByVal content As String)

Best regards,
Mikkel

 

 
Anders Ebdrup
Reply

All right, but that means, that it will not be possible to manipulate with the current description. I will try to find a work around :-)

 

Thanks Mikkel!

 
Mikkel Ricky
Reply

The value of the metadata "Description" is Pageview.get_Value("OverrideDescription") if it's set. Otherwise, i.e. in most cases, it's Page.get_Value("PageDescription"). The same goes for "Title" and "Keywords".

 

You must be logged in to post in the forum