asp.net-mvcasp.net-mvc-3mvccontribmvccontrib-grid

Html.RenderPartial is not rendering view correctly


I create a MvcContrib.UI.Grid in my ASP.NET C# MVC 3 applicatio. I create pageer for this

grid.Please see my pager code

@using MvcContrib.UI.Pager

@using MvcContrib.Pagination

@model IPagination

@Html.Pager(Model).First("First").Last("Last").Next("Next").Previous("Previous")

call the Pager.cshtml in my View. please see the below image

enter image description here

But finally it's rendering like.

enter image description here

I am clueless. Please help me.


Solution

  • If your are writing a plain string with the @ sign to the response razor automatically html encodes it for you.

    Because Html.Pager returns just a plain string containing the html so you need to use Html.Raw to prevent the automating encoding in Razor:

    So you need to change your Pager partial view to:

    @Html.Raw(Html.Pager(Model)
                  .First("First")
                  .Last("Last")
                  .Next("Next")
                  .Previous("Previous").ToString())