Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is in response to the comment above. I can't post the full code, but this is basically how my provider works.</p> <p>Suppose you have a page article.aspx, and it uses query string parameter "id" to retrieve and display an article title and body. Then this is in Web.sitemap:</p> <pre><code>&lt;siteMapNode url="/article.aspx" title="(this will be replaced)" param="id" /&gt; </code></pre> <p>Then, you create this class:</p> <pre><code>public class DynamicSiteMapPath : SiteMapPath { protected override void InitializeItem(SiteMapNodeItem item) { if (item.ItemType != SiteMapNodeItemType.PathSeparator) { string url = item.SiteMapNode.Url; string param = item.SiteMapNode["param"]; // get parameter value int id = System.Web.HttpContext.Current.Request.QueryString[param]; // retrieve article from database using id &lt;write your own code&gt; // override node link HyperLink link = new HyperLink(); link.NavigateUrl = url + "?" + param + "=" + id.ToString(); link.Text = &lt;the article title from the database&gt;; link.ToolTip = &lt;the article title from the database&gt;; item.Controls.Add(link); } else { // if current node is a separator, initialize as usual base.InitializeItem(item); } } } </code></pre> <p>Finally, you use this provider in your code just like you would use the static provider.</p> <pre><code>&lt;mycontrols:DynamicSiteMapPath ID="dsmpMain" runat="server" /&gt; </code></pre> <p>My class is more complicated than this, but these are the basics. Instead of using a querystring parameter, you could just analyze the friendly url you're using, and use that instead to retrieve the correct content. To minimize the additional db lookups with every request, you can add a caching mechanism to the provider (article title usually won't change often).</p> <p>Hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload