如何判断是否“返回”按钮或“前进”按钮被按下?
我使用 MVC2/asp.net 并尝试开发类似向导的东西。该向导将有几个网站。 用户将能够在网站 A 上输入一些信息,然后导航到 网站 B(通过按下触发 Http.Post 事件的按钮)。 到目前为止没有问题。
用户还可以在网站 B 上输入一些信息。但他有两个按钮:“后退”和“前进”。
如何识别按下了哪个按钮?
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Step2(Model model, FormCollection Form)
{
...
}
“后退”/“前进”按钮如下所示:
input type="image" name="BackButton" id="BackButton" src="http: //...无论如何.../Resources/Images/Button/BackButton.gif" alt="返回" />
输入类型=“图像”名称=“ForwardButton”id=“ForwardButton”src=“http://...whatever.../Resources/Images/Button/Forward.gif”alt=“Forward”/>
I use MVC2/asp.net and try to develop something like a wizard. This wizard will have several websites.
The user will be able to enter some information on website A and to navigate then to
website B (by pressing a button which triggers the Http.Post event).
No problem up to this point.
Also on website B can the user enter some information. But there he has two buttons: "Back" and "Forward".
How to identify here which button was pressed?
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Step2(Model model, FormCollection Form)
{
...
}
The "Back" / "Forward" buttons look like this:
input type="image" name="BackButton" id="BackButton" src="http://...whatever.../Resources/Images/Button/BackButton.gif" alt="Back" />
input type="image" name="ForwardButton" id="ForwardButton" src="http://...whatever.../Resources/Images/Button/Forward.gif" alt="Forward" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我没记错的话,通过查看
FormCollection Form
,只有执行回发的按钮应该出现。在 mvc2 中,您可以输入
[HttpPost]
而不是[AcceptVerbs(HttpVerbs.Post)]
By looking through
FormCollection Form
only the button that did the postback should be present if I remember correctly.and in mvc2 you can type
[HttpPost]
instead of[AcceptVerbs(HttpVerbs.Post)]
如果您不想查看 From 集合,您可以装饰 Action 参数
If you dont want to look at From collection you could decorate the Action paramaters