我有一个MVC 4项目,它有一个保存按钮,点击时会要求用户确认,然后将整个表单提交回控制器,模型作为输入,而不是formCollection。现在我需要在名为Submit的表单中添加另一个按钮。如何传递参数以区分“保存”和“提交”?我想继续使用JQuery函数进行确认。以下是一些代码段:
JavaScript
function SavePlan() {
if (ValidateAmounts() != true) {
var message = "Do you want to save? ";
CreateConfirmationMessage(message, '$("#form_FiscalYearPlanning").submit();');
return;
}
}
JQUERY
function CreateConfirmationMessage(message, confirmActionToTake, cancelActionToTake) {
$('#PROJECT_confirmationQuestion').html(message);
if (confirmActionToTake !== null) {
$('#button_confirmationAccept').attr('onClick', confirmActionToTake);
}
else {
$('#button_confirmationAccept').removeAttr('onClick');
}
if (cancelActionToTake !== null) {
$('#button_confirmationCancel').attr('onClick', cancelActionToTake);
}
else {
$('#button_confirmationCancel').removeAttr('onClick');
}
$('#modal_confirmation').modal('show');
}/
查看
@using (Html.BeginForm("FiscalYearPlanning", "Teammanagement", FormMethod.Post, new { id = "form_FiscalYearPlanning" }))
:::
<button class="btn btn-primary PROJECT_formButtonPopover" id="button_SavePlan" name="button_SavePlan" onClick="SavePlan();" data-toggle="popover" data-content="Save your plan, but do not submit it for review.">Save</button>
CONTROLLER
public ActionResult FiscalYearPlanning(VM_FiscalYearPlanning model)
答案 0 :(得分:0)
输入按钮具有值。您可以在控制器上检测输入按钮的值。
<input type="submit" value="submitbutton">
<input type="submit" value="savebutton">