ASP.NET MVC にある @helper ユーティリティを使用して、次のヘルパーを作成しようとしています。アイデアは、パネルを作成し、ページからこのヘルパーを呼び出して、パネルのタイトルと本文を設定することです (レイアウトを使用できないため、同じページに複数のパネルを配置したい)。
ヘルパーは次のとおりです。
@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>
}