1
我创建了一个基于解决方案here的多键表单。ASP MVC多按钮表单让JQuery拦截按钮单击
我需要jQuery拦截按钮的单击事件之一,并用模态对话框提交后手动提交。但是,当我尝试使用type =“button”时,控制器中的命令值变为null。我也尝试在我的JavaScript文件中使用preventDefault(),但是同样的事情发生。
笔者认为:
<input id="action1" type="submit" name="command" value="Action One" />
<input id="action2" type="submit" name="command" value="Action Two" />
在我的控制器:
if (command == "Action One")
{
// Do something
}
else if (command == "Action Two")
{
// Do something else
}
在我的javascript:
$('#action1').click(function (e) {
e.preventDefault();
showModalDialog();
});
感谢丹尼斯。我会尝试你的解决方案。 –