Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The best way to achieve your desired output is to ignore the SitePath control, and instead use the SiteMap's SiteMapNode's collection. The server parses the web.sitemap into a collection of SiteMapNodes and wires up the SiteMap.CurrentNode by finding a node that matches the current page's URL. Each SiteMapNode has a ParentNode property. <a href="http://msdn.microsoft.com/en-us/library/system.web.sitemap.aspx" rel="nofollow">Here is the reference page on MSDN</a>.</p> <p>So, all you need to do is check if the CurrentNode has a parent, if it does you add the ParentNode's title to the CurrentNode's title and keep going until you reach the RootNode (where you substitute your company name for the root node's title).</p> <p>Below is a quick solution; it could go in the MasterPage if you are using one. I'm not sure your language, but this should be easy to rewrite in VB.Net. I gave it a simple test and it seemed to work. You can customize the characters that separate the page titles.</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { Page.Title = SiteMapTitle(SiteMap.CurrentNode, "", " - "); } private string GetNodeTitle(SiteMapNode oNode) { if (oNode == SiteMap.RootNode) return "Company Name"; else return oNode.Title; } private string SiteMapTitle(SiteMapNode oNode, string szTitle, string szItemSeparator) { if (szTitle != string.Empty) szTitle = szTitle + szItemSeparator + GetNodeTitle(oNode); else szTitle = GetNodeTitle(oNode); if (oNode.ParentNode != null) szTitle = SiteMapTitle(oNode.ParentNode, szTitle, szItemSeparator); return szTitle; } </code></pre> <p>Hope that helps...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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