我的sp.net mvc web应用程序中有以下索引视图: -
@model IPagedList<TMS.Models.VirtualMachine>
@{
ViewBag.Title = "Virtual Machine List";
}
<h2>Virtual Machine List</h2>
<i class=" icon-plus"></i>@Html.ActionLink("Create New", "Create") | @Html.ActionLink("Assets","Asset")
//code goes here
@Html.Partial("**_PagedVMTable**",Model)
和以下_PagedVMTable
PartialView: -
@model IPagedList<TMS.Models.TMSVirtualMachine>
<div id ="VMTable">
<div class="pagedList" data-tms-target="#VMTable">
@Html.PagedListPager(Model , page => Url.Action("Index","VirtualMachine", new { searchTerm = ViewBag.searchTerm , page,sort = ViewBag.CurrentSortOrder }),
PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(PagedListRenderOptions.ClassicPlusFirstAndLast, new AjaxOptions { UpdateTargetId = "VMTable" , LoadingElementId="progress2" }))
</div>
<img src="~/Content/Ajax-loader-bar.gif" class="loadingimage" id="progress2" />
@Html.Partial("~/Views/VirtualMAchine/_VMTable.cshtml",Model)
<img src="~/Content/Ajax-loader-bar.gif" class="loadingimage" id="progress3" />
<div class="pagedList" data-tms-target="#VMTable">
@Html.PagedListPager(Model , page => Url.Action("Index","VirtualMachine", new { searchTerm = ViewBag.searchTerm , page,sort = ViewBag.CurrentSortOrder }),
PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(PagedListRenderOptions.ClassicPlusFirstAndLast, new AjaxOptions { UpdateTargetId = "VMTable" , LoadingElementId="progress3"}))
</div>
</div></div></div>
</div>
<script type="text/javascript">
$(document).ready(function () {
$("#ServerSort").click(function () {
$.ajax({
type: "Get",
url: "@Url.Action("Index","VirtualMachine")",
data: { searchTerm: "@ViewBag.searchTerm.ToString()" , page:"1" , sort: "@ViewBag.ServerSortPam" },
//contentType: "application/json; charset=utf-8",
//dataType: "json",
cache: false,
success: successFunc,
error: errorFunc
});
function successFunc(data, status) {
$("#VMTable").html(data);
}
function errorFunc() {
alert('error');
}
})
$("#RackSort").click(function () {
$.ajax({
type: "Get",
url: "@Url.Action("Index","VirtualMachine")",
data: { searchTerm: "@ViewBag.searchTerm.ToString()", page: "1", sort: "@ViewBag.RackSortPam" },
//contentType: "application/json; charset=utf-8",
//dataType: "json",
cache: false,
success: successFunc,
error: errorFunc
});
function successFunc(data, status) {
$("#VMTable").html(data);
}
function errorFunc() {
alert('error');
}
})
});
</script>
现在我面临以下问题: -
由于