MVC 附加“#”到查询字符串

发布于 2024-11-30 22:41:20 字数 431 浏览 3 评论 0原文

我为一些非常简单的事情而苦苦挣扎......帮忙吗?
我想做以下事情: 我有两个带有选项卡的页面(JQuery),我想记住选项卡选择。我决定使用查询字符串来实现这一目标,但在页面之间切换时我不知道如何传递选项卡。
示例:我有一个网址 http://localhost/Object/Edit/1#tab_tax1
我有到其他页面的链接:

 <%= Html.ActionLink(Resource.Details, "Details", new { id = Model.Object.ID })%> 

我想以某种方式传递“#tab_tax1”,所以我也将选择保留在其他页面中。

谢谢!

I struggle with something really simple... help?
I want to do the following:
I have two pages with tabs (JQuery) and I want to remember the tab selection. I decided to use the query string in order to achieve that, but switching between pages I don't know how to pass the tab.
Example: I have an url http://localhost/Object/Edit/1#tab_tax1

And I have my link to the other page:

 <%= Html.ActionLink(Resource.Details, "Details", new { id = Model.Object.ID })%> 

I want to pass somehow the "#tab_tax1" so I keep the selection in the other page too.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

离不开的别离 2024-12-07 22:41:20

不使用操作链接,只在“a”标签的 href 中编写 url:

Url.RouteUrl(new { controller = "Home", action = "Details", id = Model.Object.ID }) + "#tab_tax1"

instead of using action link compose only the url inside the href of the "a" tag:

Url.RouteUrl(new { controller = "Home", action = "Details", id = Model.Object.ID }) + "#tab_tax1"
記柔刀 2024-12-07 22:41:20

您使用 JQuery 选项卡,这意味着您可以使用 cookie。那么你实际上不需要将选项卡附加到 url 中,因为它存储在 cookie 中。

You use JQuery tabs, so that means you can use the cookies. Then you don't really need to append the tab to the url, because it is stored in the cookie.

弃爱 2024-12-07 22:41:20

使用片段参数。

Html.ActionLink(Resource.Details, "Details", controllerName, Request.Url.Scheme, Request.Url.Host, "tab_tax1", null, null)

希望这有帮助。

Use fragement parameter.

Html.ActionLink(Resource.Details, "Details", controllerName, Request.Url.Scheme, Request.Url.Host, "tab_tax1", null, null)

Hope this help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文