Maintaining the query string in ASP.Net MVC
Posted
by Mantorok
on Stack Overflow
See other posts from Stack Overflow
or by Mantorok
Published on 2010-06-15T12:34:24Z
Indexed on
2010/06/15
12:52 UTC
Read the original article
Hit count: 253
c#
|asp.net-mvc
Hi all
Just beginning my journey in ASP.Net MVC and I have a query about something before I dig myself in too deep.
I have a table, which is paged, and I have 2 controls above the table:
- Dropdown that defines order of the results and apply button next to it
- Textbox that defines a filter and apply button next to it
What I need to achieve is that if the user changes the order or adds a filter I fire of an AJAX call to my action like such: /Membership/Users?sort=value&filter=value&page=pagenumber. So my controller action is:
// GET Membership/Users?sort=&filter=&page=
public ActionResult Users(string sort, string filter, string page)
So I have 3 questions:
- Is this the correct approach?
- What would be the best way to ensure that the query string is maintained, bearing in mind that the action will nearly always be called by Jquery/Ajax functions?
- If I wanted to link directly to this action passing the arguments would I need to hard-code the querystring?
Thanks
© Stack Overflow or respective owner