简体   繁体   English

Razor多行内联模板

[英]Razor multi-line inline templates

How do you define a multi-line inline template? 如何定义多行内联模板?

For example, this grid has an inline template (the format parameter of the last column). 例如,此网格具有内联模板(最后一列的格式参数)。 What is the syntax to have multiple lines of html in the inline template? 在内联模板中有多行html的语法是什么?

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

You should just be able to have multiple lines like the fllowing: 你应该能够拥有像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's another line</p>
           </text>)
    )
)

Are you seeing any particular issues? 您是否看到任何特定问题?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM