ASP.NET MVC:添加到表单提交上的查询字符串
我正在 ASP.NET MVC 中构建网格,但遇到以下问题:
- 在网格上方,我有一个列选择器,可以让人们自定义显示的列。 这是一个带有提交按钮的表单,以便人们可以一次添加/删除多个列,而无需经过多次回发。
- 在网格下方我有分页。 这是通过actionlinks(a href)进行分页。
替代文本 http://thomasstock.net/mvcget.jpg
用户添加/删除列时会发生什么是表单被提交到 http://localhost:56156/?columnsToDisplay=EmployeeId 当然网格跳回到第 1 页。我想将网格保留在用户当前所在的页面上。 所以我需要一种方法将当前的查询字符串参数包含到表单的操作属性中。
反之亦然:我需要一种方法对操作链接执行相同的操作。 但这不太必要,因为我总是可以用按钮替换 a href 并将它们放入表单中。 但我宁愿不这样做。
我正在寻找一种无需 javascript 的解决方案!我可以自己用 javascript 完成此操作,但我希望我的网格能够在禁用 javascript 的浏览器上完美运行。
任何帮助表示赞赏。
编辑: 哦,是的,为了让它变得更难一点,我也在寻找一个没有 cookies/会话变量的解决方案。 :-)
I'm building a grid in ASP.NET MVC and I have the following issue:
- Above the grid i have a column selector which lets people customize the columns being shown. This is a form with a submit button so that people can add/remove multiple columns at once without going trough multiple postbacks.
- Below the grid I have paging. This is paging trough actionlinks (a href's).
alt text http://thomasstock.net/mvcget.jpg
What happens when a user add/removes columns is that the form gets submitted to http://localhost:56156/?columnsToDisplay=EmployeeId and ofcourse the grid jumps back to page 1. I'd like to keep the grid on the page the user was currently on. So I need a way to include the current querystring parameters into the form's action attribute.
The other way around too: I need a way to do the same with actionlinks. But this is less necessary as I could always replace the a href's with buttons and put them in a form. But I'd rather not do that.
I'm looking for a solution without javascript! I can do it myself in javascript, but I'd like my grid to work perfectly on javascript-disabled browsers.
Any help is appreciated.
Edit:
Oh yeah, to make it a bit harder, I'm also looking for a solution without cookies/session variables. :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将下面的行添加到列选择器表单中
You need to add the line below into your column selector form