带tab-id的RedirectToAction() [英] RedirectToAction() with tab-id

查看:67
本文介绍了带tab-id的RedirectToAction()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.NET MVC中有一个Web应用程序,并且在其中有一个带有表单的jqueryUI选项卡. 当我提交时,我想返回到打开选项卡.

I have a web application in ASP.NET MVC and in there i have a jqueryUI tab with forms in. And when i submit i want to return to the open tab.

和我一起RedirectToAction()创建网址

With me RedirectToAction() i create the url

www.foo.com/CV/edit/9

但是我希望能够生成

www.foo.com/CV/edit/9#tab-2

我尝试使用RedirectToAction("edit/" + id +#tab-2"),但是会生成:

I tried with RedirectToAction("edit/"+id+"#tab-2"), but that generates:

www.foo.com/CV/edit/9%23tab-2

any1知道答案吗?

any1 knows the answer?

推荐答案

创建URL,然后将#tab-2附加到URL.返回一个RedirectResult以重定向到创建的URL:

Create the URL, then append #tab-2 to it. Return a RedirectResult to redirect to the created URL:

return new RedirectResult(Url.Action("edit", new { id }) + "#tab-2");

这篇关于带tab-id的RedirectToAction()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆