C# 是否从JQUERY对话框开始发布?

C# 是否从JQUERY对话框开始发布?,c#,jquery,asp.net-mvc,jquery-ui,asp.net-mvc-4,C#,Jquery,Asp.net Mvc,Jquery Ui,Asp.net Mvc 4,我在HtmlForm中有两个按钮,它工作得非常好,为了区别,我在actionName中传递了按钮的名称。请看下面: [HttpPost] public ActionResult Index(string button, QuizCompletedViewModel q) { // QuizCompletedViewModel is the model of my razor view ... } @using (Htm

我在
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>
}
[HttpPost]
公共操作结果索引(字符串按钮,QuizCompletedViewModel q)
{//QuizCompletedViewModel是我的razor视图的模型
...            
}
@使用(Html.BeginForm(“Index”,“quick”,FormMethod.Post,new{id=“form”}))
{
@*        
*@
@对于(int i=0;i
然后,我需要更改当前视图中的两个按钮,并用这两个按钮显示一个弹出窗口,如上所示(
id=“dialog form”
)。到目前为止,当用户按下按钮并执行类似于旧代码的POST时,使用JQuery对我来说有点困难


你能帮我一把吗?

我想这可能会对你有所帮助,你必须根据自己的需要调整它,Jquery对话框在我的代码示例中显示一个Continue按钮,你可以将一个函数绑定到它,你可以将Asp.net Webforms u doPostBack替换为会在MVC页面上引起回发的东西

 $("#dialog").dialog({
                        autoOpen: false,
                        height: 380,
                        width: 650,
                        modal: true,
                        close: function () {
                            $('#btnCreateAccount').button('refresh');
                        },
                        buttons: {
                            'Continue': function () {
                                $(this).dialog('close');
                                __doPostBack($("#<%=btnCreateAccount.ClientID %>").attr("name"), '');
                            }
                        }
                    });
$(“#dialog”).dialog({
自动打开:错误,
身高:380,
宽度:650,
莫代尔:是的,
关闭:函数(){
$('#btnCreateAccount')。按钮('refresh');
},
按钮:{
“继续”:函数(){
$(this.dialog('close');
__doPostBack($(“#”).attr(“名称”),“”);
}
}
});

是的,我以你的例子为基础__doPostBack对我不起作用。我也用了$.post,但不是工作。因此,我使用了提交方法,但添加了一些额外的数据,如