开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜