2

I am implementing a non-Javascript page for a client. The page contains a number of third party grids. When JS is turned off and a sort is performed the page i,s posted back to the server , which is fine. However, I want the page to navigate to the grid that was sorted.

I can do this by using anchors, and I have tested it. However, as I am new to MVC I don't know how to append the anchor to the outgoing URL.

For example I may get a URL like Team/User/42?SortGrid1-field-asc

After it has been processed by the controller I need the URL to be sent to the client as Team/User/42?SortGrid1-field-asc#Grid1

Any ideas?

I have tried to append the anchor internally using lines like

return Redirect(Url.Action("User", "Team", new { Id = Id }) + "#Grid1");

But fail to see how to stop it going off in an infinite loop. If I redirect to another action then I go down a whole new path , which, code wise, will go on forever.

jonsca
  • 10,218
  • 26
  • 54
  • 62
Steven
  • 98
  • 1
  • 8

1 Answers1

3

Have a look at the answer to a question I posted: How can I add an anchor tag to my URL?

I think you may have to go through the controller and use generateURL to get the anchor into the url

Community
  • 1
  • 1
DevDave
  • 6,700
  • 12
  • 65
  • 99
  • I tried adding a line like: if (Session["IsJavaScriptEnabled"] == null || !(bool) Session["IsJavaScriptEnabled"]) { return Redirect(Url.Action("UserNonJs", "Team", new { Id = Id }) + "#PanelBar-2"); to the User Action Method, But it only works once because next time I come in through the nonJS Route. } How do I redirect back to the same action method without causing an infinite loop? – Steven Nov 18 '11 at 08:19