c# - Ajax.beginform 执行完整回发而不是部分回发

标签 c# ajax asp.net-mvc

在一个 View 中,我有如下的 ajax 形式:

@using (Ajax.BeginForm("ShowPartial", new AjaxOptions()
{
    InsertionMode=InsertionMode.Replace,
    UpdateTargetId="dane"
}))
{
  // My menu here
}
@Html.Partial("ShowPartial")

ShowPartial 与此 Controller 方法连接:

    public ActionResult ShowPartial(string DeviceName, string submit, int? Page)
    {
        List<Expression<Func<DeviceInstance, bool>>> where = new List<Expression<Func<DeviceInstance, bool>>>();
        int PageNo = 1;
        if (Page.HasValue)
        {
            PageNo = Page.Value;
        }
        if (DeviceName != "" && DeviceName != null)
        {
            where.Add(w => w.Device.Name.Contains(DeviceName));
        }
        return PartialView(unitOfWork.deviceInstanceRepository.Get(where, q => q.OrderBy(o => o.Id), PageNo, w => w.Device, w => w.DeviceUsage));
    }

和分部 View :

@model IEnumerable<magazyn.Models.DeviceInstance>
<table class="table table-striped" id="dane">
    <tr>
        //table headers
    </tr>

    @foreach (var item in Model)
    {
        // rendering table contet
    }

</table>

谁能告诉我为什么上面的代码进行完整回发而不是部分回发。

最佳答案

我不知道微软的ajax helpers依赖于Jquery+ Microsoft jquery plugin。 意识到我找到了需要的插件并使用包管理器下载了它。

PM> Install-Package Microsoft.jQuery.Unobtrusive.Ajax

关于c# - Ajax.beginform 执行完整回发而不是部分回发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21903665/

相关文章:

c# - asp.net 表单生成器

c# - 检查文本是否超过文本框的大小

c# - Owin 使用外部表单例份验证 cookie

c# - razor 页面上的 Dropzone 返回 400 状态代码

c# - 服务报告 "service has reported an invalid current state 0."

c# - 使用 LINQ 从列表中删除未包含的所有项目

javascript - 使用 Jquery 的简单 JWT 身份验证

css - ruby rails : adding css dynamically when rendering different partials

javascript - ajax请求symfony后刷新 View 中的数据

asp.net-mvc - ASP.NET MVC Identity - 如何更改 SMS 中生成的 token 的格式