Razor multi-line embedded patterns

How do you define a multi-line inline template?

For example, this grid has a built-in template (format parameter of the last column). What is the syntax to have multiple html lines in an inline template?

@model List<Employee>
@{
    View.Title = "Employee List";
}
@{        

   var grid = new WebGrid(source: Model,
                defaultSort: "FirstName",
                rowsPerPage: 3);
}
<p>
<h2>Employee List</h2>
<div id="grid">
    @grid.GetHtml(
        tableStyle: "grid",
        headerStyle: "head",
        alternatingRowStyle: "alt",
        columns: grid.Columns(
            grid.Column("FirstName"),
            grid.Column("LastName"),
            grid.Column("Salary",format:@<text>$@item.Salary</text>)
        )
    )
</div>
</p>
+3
source share
1 answer

You should just have some lines like fllowing:

@grid.GetHtml(
    tableStyle: "grid",
    headerStyle: "head",
    alternatingRowStyle: "alt",
    columns: grid.Columns(
        grid.Column("FirstName"),
        grid.Column("LastName"),
        grid.Column("Salary",format:@<text>$@item.Salary<br/>
           <p>Here another line</p>
           </text>)
    )
)

Do you see any special problems?

+8
source

Source: https://habr.com/ru/post/1774761/


All Articles