Search code examples
asp.net-mvcmvccontribpager

MVCContrib Pager in Razor encodes HTML


I have following code

@Html.Pager((IPagination)Model.FoundUsers).Last("<span class=\"last\">&nbsp</span>").First("<span class=\"first\">&nbsp</span>").Next("<span class=\"next\">&nbsp</span>").Previous("<span class=\"prev\">&nbsp</span>")

But it renders encoded and shows <span class="next"> on page.

I tried to used Html.Raw as suggested in Problem with razor view and mvccontrib grid pagination or How to make a pager with MVCContrib and Razor?

but it still does not work for me.

What am I doing wrong ?


Solution

  • I would assume that you are using MvcContrib v2 with Mvc4 (or possibly Mvc3)?

    Either manually download the newer libraries from http://mvccontrib.codeplex.com or use the Raw method. So instead of this:

    @Html.Pager((IPagination)Model.FoundUsers).Last("<span class=\"last\">&nbsp</span>").First("<span class=\"first\">&nbsp</span>").Next("<span class=\"next\">&nbsp</span>").Previous("<span class=\"prev\">&nbsp</span>")
    

    You would instead have:

    @Html.Raw(Html.Pager((IPagination)Model.FoundUsers).Last("<span class=\"last\">&nbsp</span>").First("<span class=\"first\">&nbsp</span>").Next("<span class=\"next\">&nbsp</span>").Previous("<span class=\"prev\">&nbsp</span>"))