在一个 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/