在形式上取消按钮 [英] Cancel button in form
问题描述
我有一个形式的取消键:
I have a cancel button in a form:
@using (Html.BeginForm("ConfirmBid","Auction"))
{
some stuff ...
<input type="image" src="../../Content/css/img/btn-submit.png" class="btn-form" />
<input type="image" src="../../Content/css/img/btn-cancel.png" class="btn-form" />
}
问题是我想这个按钮去,当我点击它的特定视图。我该怎么做呢?
The issue is I want this button to go to a particular view when I click on it. How do I do this?
推荐答案
要么你可以取消按钮转换与@ Html.ActionLink辅助方法,一个锚标记,并应用CSS类,这使得链接看起来像一个按钮,那么该链接控制器动作,您可以返回特定视图。
Either you can convert the Cancel button as an anchor tag with @Html.ActionLink helper method and apply a css class which makes the link to looks like a button and then in the controller action for that link, you can return the specific view.
@Html.ActionLink("Cancel","Index","Products",null, new { @class="clsButtonFake"})
或
使用2的形式提交按钮。一个真正的提交,一个用于取消。在你的控制器动作,检查哪个按钮调用操作方法。
你可以阅读更多关于它href=\"http://stackoverflow.com/a/8258799/40521\">这里
Use 2 submit buttons in the form. One for real submit and one for the cancel. and in your controller action, check which button called the action method. You can read more about it here in this answer.
这篇关于在形式上取消按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!