我怎样才能实现删除,并在MVC3取消按钮? [英] How can I implement a Delete and Cancel button in MVC3?
本文介绍了我怎样才能实现删除,并在MVC3取消按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表格删除记录。一个形式,我使用一个删除按钮并单击按钮时提交表单。
I have a form to delete a record. One the form I am using a delete button and when the button is clicked the form is submitted.
<input type="submit" value="Delete" />
我如何实现取消,并在行动检查它是否是删除或取消已单击?
How can I implement a cancel and check in the action if it is the delete or the cancel that has been clicked?
推荐答案
您必须给输入名称
。例如:
<input type='submit' value='Delete' name='action' />
<input type='submit' value='Cancel' name='action' />
然后在你的行动:
And then in your Action:
[HttpPost]
public ActionResult Submit(string action) {
if (action == "Delete") {
// User clicked "Delete"
} else {
// User clicked "Cancel"
}
}
这篇关于我怎样才能实现删除,并在MVC3取消按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文