Question

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...

Was it helpful?

Solution

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");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top