Frage

Here is my ASP.NET MVC 4 View (Razor) code:

@Html.Grid(Model).Columns(column =>
    {
        column.For(s => s.Description + @"<div class='results'>
            <a href='#'>Link 1</a>
            <a href='#'>Link 2</a>
        </div>").Named("Description").Encode(false);
    })

As you can see I am concatenating strings there. I would like to use Razor instead. Is there any simple way to do this?

Putting <text> instead of " doesn't work...

War es hilfreich?

Lösung

Is there any simple way to do this?

Sure, just use column.Custom instead of column.For:

column
    .Custom(
        @<text>
            <div class="results">
                <a href='#'>Link 1</a>
                <a href='#'>Link 2</a>
            </div>
        </text>
    )
    .Named("Description");
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top