문제

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

도움이 되었습니까?

해결책

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");
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top