我正在尝试使用ASP.NET MVC中的@helper实用程序创建以下Helper。 我的想法是创建一个Panel并从一个页面调用这个帮助器来设置面板的标题和主体(我希望在同一页面上有多个面板,因此我不能使用布局)。 / p>
这是帮手:
@helper PanelHelper(string title, string body){
<fieldset class="fieldset-border-2">
<legend style="display: none;">Edit</legend>
<div style="display: table;">
<div style="display: table-row;">
<div class="panel-first-row" style="display: table-cell;">
<div style="border-bottom: 1px solid #cecece; padding-left: 5px; height: 25px;">
<div style="display: table; margin: 9px 0 9px 0;">
<div style="display: table-row;">
<div class="title" style="display: table-cell;">
@title
</div>
</div>
</div>
</div>
</div>
</div>
<div class="edit-row-separator" style="display: table-row;">
</div>
<div style="display: table-row;">
<div style="display: table-cell;">
@body
</div>
</div>
</div>
</fieldset>
}
在这里我想如何打电话给这个帮手:
@Helpers.PanelHelper("Customers")
{
<div style="display: table; width: 100%;">
<div style="display: table-row; width: 100%;">
................ HTML => Customer Fields ......................
</div>
</div>
}
答案 0 :(得分:0)
你真的应该这样称呼它:
@{
string body = "<div style=\"display: table; width: 100%;\">
<div style=\"display: table-row; width: 100%;\">
................ HTML => Customer Fields ......................
</div>
</div>";
}
@PanelHelper("Customers", body)