Re: Using web.sitemap to hold SEO meta data
- From: Mark <mjhandy@xxxxxxxxx>
- Date: Thu, 21 Feb 2008 06:16:29 -0800 (PST)
On Feb 21, 8:24 am, Mark <mjha...@xxxxxxxxx> wrote:
here's what i've got so far in my code beind
if (SiteMap.CurrentNode != null) {
if (SiteMap.CurrentNode["metaKeywords"] != null)
{
strMetaKeywords = SiteMap.CurrentNode["metaKeywords"];
strMetaDescription = SiteMap.CurrentNode.Description;
}
else
{
strMetaKeywords = "this is a test";
}
}
if (!Page.IsPostBack)
Page.DataBind();
}
So, it pulls Description and metaKeyword from the siteMapNode and
populates the webform meta tags. It work well. What i'm not sure how
to do is populate steMetakeywords or strMetaDescription with content
if there is no siteMapNode for a given web form (that's what i'm
attempting to do in the ELSE statement).
any ideas?
Ok, i've made some adjustment. Here's my updated code:
if (SiteMap.CurrentNode != null)
{
if ((SiteMap.CurrentNode["metaKeywords"] != null))
{
strMetaKeywords = SiteMap.CurrentNode["metaKeywords"];
}
else
{
strMetaKeywords = "this is a test 1";
}
if (SiteMap.CurrentNode["Description"] != null)
{
strMetaDescription = SiteMap.CurrentNode.Description;
}
else
{
strMetaDescription = "this is the description from
code behind";
}
}
if (!Page.IsPostBack)
Page.DataBind();
It works fine, expect for a small bug. If siteMapNode is as follows:
<siteMapNode url="~/index.aspx" title="Home" description=""
metaKeywords="" id="homeNavItem">
the canned metaKeyword message doesn't display.
any thoughts?
.
- References:
- Using web.sitemap to hold SEO meta data
- From: Mark
- Using web.sitemap to hold SEO meta data
- Prev by Date: Re: Limit number of COM+ sessions
- Next by Date: LINQ for SQL Aggregates
- Previous by thread: Using web.sitemap to hold SEO meta data
- Next by thread: Sort structure on date
- Index(es):