title: Ajax.Pager not working in MVC4
body: <p>I was using Ajax.Pager in MVC 2 which worked fine.Here is the code in the view </p>
  
  <pre><code>&lt;%= Ajax.Pager(new AjaxOptions { UpdateTargetId = ViewData.Model.UpdateTargetId, OnBegin = "beginPagings", OnSuccess = "successPagings", OnFailure = "failurePaging" },
          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"] })%&gt;
  </code></pre>
  
  <p>and this is the AJax link builder code</p>
  
  <pre><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);
          }
  </code></pre>
  
  <p>But now when I upgrade to MVC 4 this is not generating links as expected.</p>
  
  <p>Here is the MVC 4 code I use in the view</p>
  
  <pre><code>@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"] })
  </code></pre>
  
  <p>But the link generated is like below and its no more a link. Its rendered as plain text.</p>
  
  <pre><code>&lt;a data-ajax="true" data-ajax-begin="beginPagings" data-ajax-failure="failurePaging" data-ajax-mode="replace" data-ajax-success="successPagings" data-ajax-update="#divGrid" href=""&gt;2&lt;/a&gt;
  </code></pre>
  
  <p>I came across <a href="http://code-inside.de/blog-in/2011/04/26/howto-ajax-actionlink-asp-net-mvc-3/" rel="nofollow noreferrer">a article</a> which says its because of “unobtrusive Javascript”.
  Am I missing something??</p>
  
  <p>This issue may be linked to a <a href="https://stackoverflow.com/questions/9050145/html-encode-decode-c-sharp-mvc4">similar issue in stack overflow</a></p>