在父母面包屑preserving查询字符串PARAMS(的SiteMapPath) [英] Preserving query string params in parent breadcrumb (SiteMapPath)
问题描述
我正在寻找一种方式来preserve查询字符串参数导航回到堆栈使用标准&LT时,ASP:的SiteMapPath>
实施
I'm looking for a way to preserve query string parameters when navigating back up the stack using the standard <asp:SiteMapPath>
implementation.
为了简单起见,假设我有一个动物&GT;滋生
页堆栈:
For simplicity, suppose I have a Animal > Breed
page stack:
<siteMapNode url="~/Animal.aspx" title="Animal" >
<siteMapNode url="~/Breed.aspx" title="Breed"/>
</siteMapNode>
我浏览到 Animal.aspx?类型=狗
键,选择一个品种的狗,导航到 Breed.aspx?类型=斗牛犬
I navigate to Animal.aspx?type=Dog
and select a dog breed to navigate to Breed.aspx?type=Bulldog
在 Breed.aspx
我有正确的痕迹动物&GT;滋生
但动物
URL仅仅是 Animal.aspx
。我怎样才能获得动物链接是父/ previous页 Animal.aspx?类型=狗
?
On Breed.aspx
I have the correct breadcrumb Animal > Breed
but the Animal
url is just Animal.aspx
. How can I get the Animal link to be the parent/previous page Animal.aspx?type=Dog
?
在这个简单的例子我知道我可以切实添加所有的动物类型及其相关的类型单独的节点。我的实际设置较为复杂并且需要从数据库中读取的ID。
In this simplistic example I realise I could feasibly add all the animal type as separate nodes with their relevant type. My actual setup is more complicated and requires ids to be read from the a database.
推荐答案
答案这里我已经加入后续的详细页面(Breed.aspx中的例子)
As accepted answer here I have added the follow to the detail page (Breed.aspx in the example)
protected void Page_Load(object sender, EventArgs e){
if (!IsPostBack)
SiteMap.SiteMapResolve += new SiteMapResolveEventHandler(SiteMap_SiteMapResolve);
}
SiteMapNode SiteMap_SiteMapResolve(object sender, SiteMapResolveEventArgs e){
SiteMapNode currentNode = SiteMap.CurrentNode.Clone(true);
currentNode.ParentNode.Url += "?type=" + this.Breed.AnimalType;
return currentNode;
}
修改
<击>似乎运作良好击>
URL被更新。但是我用CurrentNode很多我的菜单控件导航向上和向下的站点地图。当我克隆我失去兄弟的信息打破我的菜单。
The url is updated however I use CurrentNode a lot in my menu controls navigating up and down the site map. When I clone I lose sibling information breaking my menus.
我要么需要找到克隆的方式,也preserves整个地图或找到修改ParentNode.Url的另一种方式。
I either need to find a way of cloning which preserves the entire sitemap or find another way of amending the ParentNode.Url
这篇关于在父母面包屑preserving查询字符串PARAMS(的SiteMapPath)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!