1
我有我的MVC局部视图字母寻呼机:我怎样才能让我的HTML辅助方法让Ajax请求,而不是加载整个页面在MVC
<div class="pagination pagination-left pagination-mini">
<ul>
<li>
@Html.AlphabeticalPager(ViewData["CurrentPage"].ToString(), x => Url.Action("Test", new { page = x }))
</li>
</ul>
</div>
我的控制器动作:
public ActionResult Test(string page)
{
var items = x => x.Name.StartsWith(page, true, null);
ViewData["CurrentPage"] = page ?? string.Empty;
return PartialView(items.ToList());
}
我的助手方法:
public static MvcHtmlString AlphabeticalPager(this HtmlHelper html, string currentPage, Func<string, string> pageUrl)
{
//code here which creates the list for a page and returns below
return MvcHtmlString.Create(result.ToString());
}
目前,当我点击一个寻呼机例如,“A”,它加载的局部视图在新窗口而不是在局部视图所在的主视图中。我希望调用/请求在Ajax中,以便布局保持不变。