【发布时间】:2013-06-10 02:33:03
【问题描述】:
目标
使用 C# + MVC 4 + Razor 引擎创建共享 UI 模板。
问题
我不知道该怎么做。
详情
我有以下模板:
<li>
<div class="introduction">
<h3>{productName}</h3>
</div>
<div class="presentation">
<img src="{productImage}" alt="" />
</div>
<div class="description">
<p>Starting by</p>
<h3>{minProductPrice}</h3>
<p class="product-unity">/a <span class="product-measure"
data-measure-shortcut="{productMeasureShortname">{productMeasureName}
</span></p>
</div>
<div class="controls">
<button class="button green add" title="Add to comparsion list">+</button>
<div class="tooltip-quantity">
<p class="float-left">Quantity:</p>
<form method="post" action="#">
<input class="quantity float-left" name="product_quantity"
maxlength="2" type="text" />
<span class="float-left">/{productMeasureName}(s)</span>
<button disabled class="button orange filled float-right">
Add
</button>
</form>
</div>
<button class="button light-blue filled compare float-right" title="This product is available in 6 stores">Compare</button>
</div>
</li>
当我想调用它时,我会做这样的事情:
@Html.RenderMyTemplate("Product Name", "Product Image", "Min Product Price"...)
从逻辑上讲,参数将替换模板上的占位符。
有什么想法吗?
提前致谢!
【问题讨论】:
标签: c# asp.net-mvc-4 razor