覆盖查询字符串传递的参数
我有以下问题
我有一个用经典 asp 构建的 Web 框架,它将页面状态保存在隐藏文本框中,然后向自身发出提交。
在提交之前,我们有一个 JavaScript 函数将操作保存在隐藏的“操作”输入中,然后执行提交。
该页面从这些隐藏文本中加载状态,读取发出的操作,读取额外的参数(例如要编辑的记录的 ID),然后相应地构建页面。
我想创建一个 url 链接,以通过对“x”id 进行“编辑”操作来自动启动页面。
所以我正在考虑构建以下网址,例如
http://myapp/user?action= edit&id=23
问题是当页面自动提交时,que url字符串保留参数。
我想实现以下目标:
当用户单击
http://myapp/user? action=edit&id=23
我的页面应该收到发布的值 action=edit 和 id=23
但 url 应该只是 http://myapp/user
并且两个参数都应该保留在隐藏文本中...(我想知道我是否清楚自己...)
非常感谢
saludos
sas
ps:我有几个想法关于如何解决它,但我会将它们作为答案发布......
I have the following problem
I have a web framework built with classic asp that saves the page state in hidden textboxes, and then issues a submit to itself.
Before submitting, we have a javascript functions that saves the action in a hidden "action" input, and then performs the submit.
The page loads the state from those hidden texts, reads the action issued, reads extra parameters, like the id of the record to edit, and then builds the page accordingly.
I'd like to make a url link to automatically start the page with "edit" action on a "x" id.
So I was thinking about building the following url, for example
http://myapp/user?action=edit&id=23
the problem is that when the page auto-submits, que url string keeps the parameters.
I'd like to achieve the following:
when the user clicks on
http://myapp/user?action=edit&id=23
my page should receive the posted values action=edit and id=23
but the url should be just http://myapp/user
and both parameters should be kept in the hidden texts... (I wonder if I make myself clear...)
thanks a lot
saludos
sas
ps: I have a couple of ideas about how to solve it, but I'll post them as answers...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想到的第一个解决方案是将值保存在会话中,发出不带参数的重定向,然后加载参数并将它们从会话中删除......
The first solution that came to my mind was to save the values in the session, issue a redirect without the parameters, and then load the parameters and remove them from the session...
另一种解决方案,也是最容易实现的解决方案,是每当我读取参数时,我首先从查询字符串(request.queryString)中读取它们,然后从发布的值(request.form)中覆盖它们,
这样我就不会关心查询字符串中的参数不断发送,剩下的唯一问题是烦人的网址......
the other solution, and the easiest one to implement, is that whenever I read parameters I first read them from the querystring (request.queryString) and then overwerite them from the posted values (request.form)
that way I wouldn't care if the parameters from the querystring keep being sent, the only problem left would be the annoying url...