MVCContrib Pager in Razor encodes HTML
-
25-02-2021 - |
Question
I have following code
@Html.Pager((IPagination)Model.FoundUsers).Last("<span class=\"last\"> </span>").First("<span class=\"first\"> </span>").Next("<span class=\"next\"> </span>").Previous("<span class=\"prev\"> </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 ?
La 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\"> </span>").First("<span class=\"first\"> </span>").Next("<span class=\"next\"> </span>").Previous("<span class=\"prev\"> </span>")
You would instead have:
@Html.Raw(Html.Pager((IPagination)Model.FoundUsers).Last("<span class=\"last\"> </span>").First("<span class=\"first\"> </span>").Next("<span class=\"next\"> </span>").Previous("<span class=\"prev\"> </span>"))
Autres conseils
Perhaps it's because I am working in VB, but I had to get the appropriate string from the Pager object:
@Html.Raw(Html.Pager(Model).ToString)
I'm using MvcContrib 2.0.95 with MVC 3.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow