【发布时间】:2011-06-09 15:32:45
【问题描述】:
我正在使用将数据和元数据包装在一个属性中的旧模型。对于这个问题,假设界面是:
pubic interface ILegacyCheckbox
{
bool Value { get; set; }
bool Editable { get; set; }
}
我想用自己的方法包装 CheckBoxFor() 扩展方法,
public static MvcHtmlString LegacyCheckboxFor<TModel>(
this HtmlHelper<TModel> html,
Expression<Func<TModel, ILegacyCheckbox>> expression)
{
// wrap html.CheckBoxFor() method here by extracting the Value
// property and check if Editable is false, in which case add
// an htmlAttribute of "disabled=true"
}
有没有办法做这样的事情?我该从哪里开始?
任何帮助将不胜感激,
谢谢,
亚历克斯
【问题讨论】:
标签: asp.net-mvc linq asp.net-mvc-3 expression-trees