ASP.NET MVC: add to querystring on form submit

I am creating a grid in ASP.NET MVC and I have the following problem:

  • Above the grid, I have a column selector that allows me to personalize the displayed columns. It is a form with a submit button so people can add / remove multiple columns at once without missing multiple postbacks.
  • Below the grid, I have paging. These are actionlinks (href's) paging trump cards.

alt text http://thomasstock.net/mvcget.jpg

What happens when the user adds / removes columns is that the form is submitted to http: // localhost: 56156 /? ColumnsToDisplay = EmployeeId , and of course the grid goes to page 1. I want to keep the grid on the page where was a user. I need a way to include the current request parameters in a form action attribute.

Conversely: I need a way to do the same with actionlinks. But this is less necessary as I could always replace the href with buttons and put them on the form. But I don't want to do this.

I am looking for a solution without javascript! I can do this myself in javascript, but I would like my grid to work fine in browsers with javascript disabled.

Any help is appreciated.

Edit: Oh yeah, to make it a little more complicated, I'm also looking for a cookie / session variable free solution. :-)

+1


a source to share


1 answer


You need to add below line to column select form



<input type="hidden" name="page" value="<%=Request.QueryString["page"]%>" />

      

+5


a source







All Articles