我里面有两个按钮HtmlForm
,它工作得很好,为了区分我在 actionName 中传递按钮的名称。往下看:
[HttpPost]
public ActionResult Index(string button, QuizCompletedViewModel q)
{ // QuizCompletedViewModel is the model of my razor view
...
}
@using (Html.BeginForm("Index", "Quiz", FormMethod.Post, new { id = "form" }))
{
<div>
<!-- Old code using two buttons for post -->
<div class="float-right">
@* <input name="button" type="submit" value="save" />
<input name="button" type="submit" value="done" />*@
<input name="button" type="button" value="done" />
</div>
<div id="dialog-form">
<input name="button" type="button" value="Cancel" />
<input name="button" type="submit" value="Save" />
<input name="button" type="submit" value="Done" />
</div>
</div>
<div id="question-container">
@for (int i = 0; i < Model.Questions.Count; i++) {
...
}
</div>
}
然后我需要更改当前视图的两个按钮,并显示带有这两个按钮的弹出窗口,如上所示(id="dialog-form"
)。到目前为止,当用户按下按钮并像旧代码一样执行 POST 时,使用 JQuery 对我来说有点困难。
你能帮我一把吗?