Asp.net mvc 2 上载asp.net mvc 2后不会出现对话框

Asp.net mvc 2 上载asp.net mvc 2后不会出现对话框,asp.net-mvc-2,jquery-dialog,Asp.net Mvc 2,Jquery Dialog,上传成功后,我的对话框不会弹出?上载工作正常,但$dialog-confirm.dialog不工作 <h2> upload Data</h2> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs

上传成功后,我的对话框不会弹出?上载工作正常,但$dialog-confirm.dialog不工作

<h2>
    upload Data</h2>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script src="../../Scripts/jqueryform.js" type="text/javascript"></script>
<script src="../../Scripts/jblock.js" type="text/javascript"></script>

<script src="../../Content/jquery-ui-1.8.12.custom/js/jquery-ui-1.8.12.custom.min.js"
    type="text/javascript"></script>

<link href="../../Content/jquery-ui-1.8.12.custom/css/ui-lightness/jquery-ui-1.8.12.custom.css"
    rel="stylesheet" type="text/css" />



<script type="text/javascript">
    $(function () {
        $("#ajaxUploadForm").ajaxForm({
            iframe: true,
            dataType: "json",
            beforeSubmit: function () {
                $("#ajaxUploadForm").block({ message: '<h1><img src="/Content/busy.gif" /> uploading file...</h1>' });
            },
            success: function (result) {
                $("#ajaxUploadForm").unblock();
                $("#ajaxUploadForm").resetForm();
                $.growlUI(null, result.message);

                //alert(result.message);

                //does not popup??
                $("#dialog-confirm").dialog({
                    resizable: false,
                    height: 140,
                    modal: true,
                    buttons: {
                        "Ok":
                        function () {
                            alert('ok');
                            $(this).dialog("close");
                        }
                    ,
                        Cancel: function () {
                            $(this).dialog("close");
                        }
                    }
                });


            },
            error: function (xhr, textStatus, errorThrown) {
                $("#ajaxUploadForm").unblock();
                $("#ajaxUploadForm").resetForm();
                $.growlUI(null, 'Error uploading file');
            }
        });
    });
</script>
<form id="ajaxUploadForm" action="<%= Url.Action("AjaxUpload", "Home")%>" method="post"    enctype="multipart/form-data">
<fieldset>
    <legend>Upload a file</legend>
    <label>
        File to upload:
        <input type="file" name="file" />(100MB max size)</label>
    <input id="ajaxUploadButton" type="submit" value="Submit" />
</fieldset>
</form>


  public FileUploadJsonResult AjaxUpload(HttpPostedFileBase file)
    {
        // TODO: Add your business logic here and/or save the file
        System.Threading.Thread.Sleep(2000); // Simulate a long running upload

        // Return JSON
        return new FileUploadJsonResult { Data = new { message = string.Format("{0} uploaded successfully.", System.IO.Path.GetFileName(file.FileName)) } };
    }

我看到您正在使用插件对表单进行Ajaxification并从控制器操作返回JSON。以下是关于此场景的说明:

因为无法上传 使用浏览器的 XMLHttpRequest对象,表单插件 使用隐藏的iframe元素提供帮助 完成任务。这是一个常见的问题 技术,但它有内在的 局限性iframe元素是 用作窗体的目标 提交操作,这意味着 服务器响应将写入 iframe。这是好的,如果响应 类型是HTML或XML,但不起作用 如果响应类型是script,也可以 或者JSON,两者通常都包含 需要重复的字符 在中找到实体引用时使用实体引用 HTML标记

考虑到 脚本和JSON响应 插件允许对这些响应进行修改 嵌入在textarea元素中,并且 建议您这样做 这些响应类型在中使用时 与文件上传合并

因此,要使其正常工作,服务器的响应需要如下所示:

<textarea>{ message: 'file uploaded successfully' }</textarea>

这就是这个自定义FileUploadJsonResult在控制器操作中所做的吗?

是的,这是我的FileUploadJsonResult:public类FileUploadJsonResult:JsonResult{public override void executesUltControllerContext上下文{this.ContentType=text/html;context.HttpContext.Response.Write;base.ExecuteResultcontext;context.HttpContext.Response.Write;}}