471,123 Members | 914 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,123 software developers and data experts.

dynamic SiteMapPath

I’m trying to create a dynamic asp.net 2.0 siteMapPath control (using VB.net).
Using the xml sitemap I’ve got these three pages:

productGroup.aspx
productListing.aspx
productDetail.aspx

Each page receives a query string i.e. productGroup.aspx?id=9

The page then renders with the appropriate details which have been accessed
from an SQL 2005 database.

The siteMapPath looks like this:

Home / Product Group / Product Listing / Product Detail

What I’d like to do is to dynamically change the SiteMapPath, depending on
the product selected. It should then look something like:

Home / Widgets / Large Widgets / Widget No16

I’ve read the following article:
http://msdn2.microsoft.com/en-us/library/ms178425.aspx which has given me
some ideas - but its raised far more questions!

My questions are:

1. How do I capture the query string i.e. the number ”9” of ?id=9 and pass
it into a
variable?
2. How can I programmatically change the siteMapPath name property to show
something more meaningful i.e. instead of ‘Product Group’ show ‘Widgets’?
3. How do you use the HttpContext object as referenced in the MSDN Article?

Hope someone out there can help

Thanks

Mar 15 '07 #1
2 4097
Question 1:

//C#
string varAsString = Request.QueryString["id];
int ID;

if(varAsString != null)
{
ID = int.Parse(varAsString);
}

'VB.NET
Dim varAsString as String = Request.QueryString("id")
Dim ID as Integer

If Not (varAsString Is Nothing) Then
ID = Int32.Parse(varAsString)
End If

Question 2:
-----------
Out of the box, the SiteMapPath works against .sitemap. You can customize
the way it works through a custom provider (and thereby use a database
instead, for example), but you cannot do allof the dynamic lookups you will
need on the default provider. Worst case is inheriting from SiteMapPath and
creating your own custom control.

Question 3:
------------
HttpContext.Current to get the current context:
http://odetocode.com/Articles/112.aspx

You can then use the instance methods, as described in the MSDN
documentation. Not sure if I am answering the question, as I am not sure
precisely what you are doing with it (did not have time to read the URL you
posted, apologies), but it should point you in the correct direction.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*********************************************
Think outside the box!
*********************************************
"James Page" <Ja*******@discussions.microsoft.comwrote in message
news:D3**********************************@microsof t.com...
I’m trying to create a dynamic asp.net 2.0 siteMapPath control (using
VB.net).
Using the xml sitemap I’ve got these three pages:

productGroup.aspx
productListing.aspx
productDetail.aspx

Each page receives a query string i.e. productGroup.aspx?id=9

The page then renders with the appropriate details which have been
accessed
from an SQL 2005 database.

The siteMapPath looks like this:

Home / Product Group / Product Listing / Product Detail

What I’d like to do is to dynamically change the SiteMapPath, depending on
the product selected. It should then look something like:

Home / Widgets / Large Widgets / Widget No16

I’ve read the following article:
http://msdn2.microsoft.com/en-us/library/ms178425.aspx which has given me
some ideas - but its raised far more questions!

My questions are:

1. How do I capture the query string i.e. the number ”9” of ?id=9 and pass
it into a
variable?
2. How can I programmatically change the siteMapPath name property to show
something more meaningful i.e. instead of ‘Product Group’ show ‘Widgets’?
3. How do you use the HttpContext object as referenced in the MSDN
Article?

Hope someone out there can help

Thanks
Mar 15 '07 #2
Thanks for your reply I'll let you know how I get on

Mar 15 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Robert Camsky | last post: by
reply views Thread by Not Me | last post: by
1 post views Thread by Danial | last post: by
5 posts views Thread by Jon via DotNetMonster.com | last post: by
3 posts views Thread by Uriah Piddle | last post: by
1 post views Thread by =?Utf-8?B?bWljaGFlbHJp?= | last post: by
reply views Thread by =?Utf-8?B?TWFoZXNoIE5pbWJhbGthcg==?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.