1
如何将模型作为参数传递给自定义的HTML助手?剃刀声明式助手传递模型作为参数
目前,我有以下文件
@helper LabelFor(string label, string hint)
{
<label for="@label">@label</label>
<span class="mif-info"
data-role="hint"
data-hint-background="bg-blue"
data-hint-color="fg-white"
data-hint-mode="1"
data-hint-position="top"
data-hint="@hint"></span>
}
被称为与
@MyHelpers.LabelFor(Html.DisplayNameFor(model => model.Title).ToString(), "Description")
我怎么可以把它简化为
@MyHelpers.LabelFor(model => model.Title, "Description")
它不可能在'@ helper'中使用表达式(至少具有泛型类型参数)。改为使用'HtmlHelper'扩展方法。 –