Hello. I want my ASP.NET site to have simple menu string aka Breadcrumbs. I have created Sitemap with all required elements and registered into Web.config. For example:

    <siteMapNode url="Default.aspx" title="Home" >
     <siteMapNode url="hosting/Default.aspx" title="Hosting" />
     <siteMapNode url="software/Default.aspx" title="Software">
      <siteMapNode url="firefox/Default.aspx" title="Firefox">
       <siteMapNode url="Download.aspx" title="Download" />
       <siteMapNode url="Support.aspx" title="Support" />

And created a control placed on Masterpage. Here it's menu generation code:

protected void Control_Load(Object sender, EventArgs e)
 string path = String.Empty;
 StringCollection list = new StringCollection();

 foreach (string str in Request.Url.Segments)
  path += str;
  string link = String.Format("<a href=\"{0}://{1}{2}\">{3}</a>", Request.Url.Scheme, Request.Url.Authority, path, this.names[str]);

 foreach (string str in list)
  menu += String.Concat(str, SeparatorLine);
 menu = menu.Remove(menu.LastIndexOf(SeparatorLine));

But it uses a StringDictionary like { { "/", "Home" }, { "hosting/", "Hosting" }, { "software/", "Software" } .. }

How can I use a query to Sitemap instead of it? Or maybe something else, not Sitemap, but beforehand invented.

+4  A: 

You can use the SiteMapPath control (should be in the Navigation category of your toolbox). Check this page for a tutorial.

+6  A: 

ASP.NET SiteMapPath Control

<asp:SiteMapPath ID="SiteMapPath1" Runat="server" />
Rex M
+1  A: 

Just set the SiteMapProvider property to the provider for the sitemap you want to use for the breadcrumbs and you'll be set. I usually just place the SiteMapPath inside a div and set the CSS on the div to style the breadcrumbs.

One gotcha to look out for though. If you suppress any root nodes in the sitemap, they will still show up in your breadcrumbs. I've run into this by trying to use the same sitemap for breadcrumbs and for the SiteMapDataSource for a treeview where I wanted to not show the starting node.

Good luck!

@Tim: There is an example of how to hide rendered root nodes in a `OnItemCreated` handler here: Basically it sets nodes' `Visible` property to `false`, if node happens to be a root node.