dynamic SiteMapPath

G

Guest

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
 
C

Cowboy \(Gregory A. Beamer\)

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!
*********************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top