开发者

SiteMapPath: change the title and link of the last link in chain

开发者 https://www.devze.com 2023-02-02 12:12 出处:网络
Hi Can you advise please any solution? I have a SiteMapPath control and instead of default functionality like

Hi Can you advise please any solution? I have a SiteMapPath control and instead of default functionality like

Home > Accounts > User Account

where "User Account" refers to ~/UserAccount.aspx

I would like to overwrite the last node to show info about a current user, i.e.开发者_运维问答:

Home > Accounts > John White

and "John White" refers to ~/UserAccount.aspx?id=111 ?


Yeah, you have to inherit from the XmlSiteMapProvider and override its BuildSiteMap method. In here you can manipulate any nodes you want at runtime, which will then show up in your SiteMapPath control.

public class MySiteMapProvider : XmlSiteMapProvider
{
   ...

   public override SiteMapNode BuildSiteMap()
   {
     var node = base.BuildSiteMap();
     var userAccountsNode = this.FindUserAccountsNode(node);

     userAccountsNode.ReadOnly = false;
     userAccountsNode.Title = ...;
     userAccountsNode.Url = ...;
     userAccountsNode.ReadOnly = true;

     return node;
   }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消