开发者

RedirectToAction() with tab-id

开发者 https://www.devze.com 2023-04-12 00:05 出处:网络
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.

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.

With me RedirectToAction() i create the url

www.foo.com/CV/edit/9

But i want to be able to generate

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

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

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

any1 knows the answer?


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");


You can't redirect to a hashed URL because they aren't a physical URL. The hash is used for internal page anchoring. You'd be best off using a URL parameter like &tab=2

0

精彩评论

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

关注公众号