3

I have the following partial view code

@model IEnumerable<PDoc.Web.Models.UserDocModel>
@using MvcContrib.UI.Grid;
@using MvcContrib.UI.Pager;
@using MvcContrib.Pagination;

<div id="docList">
@Html.Grid(Model).Columns( column => {
    column.For( u => u.Description ).Named( "Description" );
    column.For( u => u.FileName ).Named( "File name" );
    column.For( u => u.FileSize ).Named( "Size" );
    column.For( u => u.UploadDate.ToShortDateString() ).Named( "Upload Date" );
    } ).Attributes( @class => "table-list" ).Empty( "No documents uploaded" )

    <div style="position:absolute; bottom: 3px; width: 95%;">
        @Html.Pager( (IPagination)Model )..First( "First" ).Next( "Next" ).Previous( "Previous" ).Last( "Last" ).Format( "{0}-{1} di {2}" )
    </div>
</div>

This renders encoded html for the pagination as in the following snippet copied with Chrome Developer Tool

<div id="myDocs">
  <div id="docList">
     <table class="table-list">...</table>
     <div style="position:absolute; bottom: 3px; width: 95%;">
        &lt;div class='pagination'&gt;&lt;span class='paginationLeft'&gt;1-1 di 1&lt;/span&gt;&lt;/div&gt;
    </div>
</div>

Why?

Also with Chrome DT I can see two double quote surrounding the encoded markup. Is that only a way to show something tht's encoded?

alt text

Lorenzo
  • 29,081
  • 49
  • 125
  • 222

1 Answers1

6

I think it's getting double encoded. If you put the Html.Pager stuff inside of an Html.Raw() method, it should work.

mdm20
  • 4,475
  • 2
  • 22
  • 24
  • Razor automatically encodes everything. The built in Html methods now return MvcHtmlStrings that account for this. The Html.Pager method you are using probably returns a plain string, which Razor encodes. – mdm20 Dec 30 '10 at 01:30
  • 2
    @Html.Raw(Html.Pager(Model).First( "First" ).Next( "Next" ).Previous( "Previous" ).Last( "Last" ).Format( "{0}-{1} di {2}" ).ToString()) would be the syntax for reference. – Bryan Corazza Jan 27 '11 at 21:52
  • 1
    Looks like the MVC 3 - 3.0.51.0 version of the Contrib library does not need the this solution, just use @Html.Pager(). – Bryan Corazza Jan 30 '11 at 03:28