gpt4 book ai didi

c# - 如何制定一个带有哈希 (#) 的 MapPageRoute?

转载 作者:行者123 更新时间:2023-11-30 17:12:49 25 4
gpt4 key购买 nike

我正在使用 MapPageRoute 创建到页面的路由,效果很好。但是,我希望页面滚动到底部以显示具有 id bottom 的特定 div。我已尝试创建以下路由,但哈希值已在 URL 中进行编码,因此页面不会向下滚动。

RouteTable.Routes.MapPageRoute("Topics", 
"onderwerpen/{ID}/{name}#bottom",
"~/TopicPage.aspx"
);

结果:

mydomain/onderwerpen/1/title%23bottom

当这样调用时:

Response.RedirectToRoute("Topics", new { ID = 1, name = "title" });

最佳答案

我想我自己找到了最合适的解决方案。此答案可供讨论。

string url = Page.GetRouteUrl("Topics", new { ID = 1, name = "title" });
Response.Redirect(url + "#bottom");

关于c# - 如何制定一个带有哈希 (#) 的 MapPageRoute?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10371331/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com