mvc html.ajaxpager,c# - Ajax.Pager not working in MVC4 - Stack Overflow

I was using Ajax.Pager in MVC 2 which worked fine.Here is the code in the view

ViewData.Model.PageSize, ViewData.Model.PageNumber, ViewData.Model.TotalItemCount, new { controller = ViewContext.Controller.ControllerContext.RouteData.Values["Controller"], action = ViewContext.Controller.ControllerContext.RouteData.Values["action"], Id = ViewContext.Controller.ControllerContext.RouteData.Values["id"], str = ViewContext.Controller.ControllerContext.RouteData.Values["str"] })%>

and this is the AJax link builder code

private MvcHtmlString GeneratePageLink(string linkText, int pageNumber)

{

var pageLinkValueDictionary = new RouteValueDictionary(this.linkWithoutPageValuesDictionary);

pageLinkValueDictionary.Add("page", pageNumber);

return ajaxHelper.ActionLink(linkText, pageLinkValueDictionary["action"].ToString(), pageLinkValueDictionary, ajaxOptions);

}

But now when I upgrade to MVC 4 this is not generating links as expected.

Here is the MVC 4 code I use in the view

@Ajax.Pager(new AjaxOptions { UpdateTargetId = Model.UpdateTargetId, OnBegin = "beginPagings", OnSuccess = "successPagings", OnFailure = "failurePaging" },

Model.PageSize, Model.PageNumber, Model.TotalItemCount, new { controller = ViewContext.Controller.ControllerContext.RouteData.Values["Controller"], action = ViewContext.Controller.ControllerContext.RouteData.Values["action"], Id = ViewContext.Controller.ControllerContext.RouteData.Values["id"], str = ViewContext.Controller.ControllerContext.RouteData.Values["str"] })

But the link generated is like below and its no more a link. Its rendered as plain text.

2

I came across a article which says its because of “unobtrusive Javascript”.

Am I missing something??