asp.net-mvc-3 – 使用Ajax.BeginForm工作的mvc 3局部视图(发布到新表单arrgh)

我有一个2列的mvc 3表格.左列是树视图,当选择节点时,id =’partialView’的div将更新以显示该节点的详细信息.这似乎工作正常.
编辑表单(部分视图)在id =’partialView’的div中加载.

现在问题发生在用户提交此部分视图时…现在它确实回发到控制器并且正确的方法但是结果没有返回到具有id =’partialView’的div但是发布到新页面.

所以这就是我希望局部视图发布并返回替换现有局部视图的场景.

这可能吗?

我在下面包含我的代码以供我的部分观点…

@model DataModel.Code



@using (Ajax.BeginForm("Edit","Code",new AjaxOptions {
                                    UpdateTargetId = "partialView",HttpMethod="POST"

                                    }   
                                    )) {    


    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Code</legend>


        @Html.HiddenFor(model => model.CodeID)

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>

        <div class="editor-field">
            @Html.EditorFor(model => model.Note)
            @Html.ValidationMessageFor(model => model.Note)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.DateModified)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.DateModified)
            @Html.ValidationMessageFor(model => model.DateModified)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.TopicID)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.TopicID)
            @Html.ValidationMessageFor(model => model.TopicID)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Special)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Special)
            @Html.ValidationMessageFor(model => model.Special)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Html)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Html)
            @Html.ValidationMessageFor(model => model.Html)
        </div>

        <p>
            <input type="submit" value="Save" />

        </p>



    </fieldset>
}



<div>
    @Html.ActionLink("Back to List","Index")
</div>


@Html.Telerik().ScriptRegistrar().jQuery(true)

<script type="text/javascript">

    $(document).ready(function () {



    });


</script>

解决方法

包括

<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>

在你的_Layout.cshtml中

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....