2
我需要調用一個HTML助手來傳遞模型中的兩個屬性。問題是,當我試試這個:Html擴展與lambda模型的兩個屬性
@Html.BsDropDownFor(x => x.Type.Id, x => x.Type.Descripcion, (IEnumerable<TextValue>)ViewBag.ClaseB)
頁眉方法的定義如下:
public static MvcHtmlString BsDropDownFor<TModel>(this HtmlHelper<TModel> htmlHelper,
Expression<Func<TModel, TProperty>> expressionValue,
Expression<Func<TModel, TProperty>> expressionText,
IEnumerable<TextValue> items)
如果我定義
BsDropDownFor<TModel,TProperty>
做,預計在兩個參數相同的屬性。
我應該如何定義接收兩個屬性的方法?
更新2015年3月3日
那麼我的最後延長工作
改變了我的簽名
public static MvcHtmlString BsDropDownFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper,
Expression<Func<TModel, TProperty>> expression,
string elementIdText,
IEnumerable<TextValue> items)
expressionText是建立其他擴展方法和觀點被稱爲
@Html.BsDropDownFor(x => x.Type.Id, Html.ModelPropertyTagId(x => x.Type.Descripcion), (IEnumerable<TextValue>)ViewBag.ClaseB)
關於
我的預期發現了一些如何@Html ...(新[] {X => x.Type.Id,X => X .Type.Description},..其他參數),謝謝JLRishe – 2015-03-03 21:29:25
你是對的,重構後代碼中加入了兩個類型參數和HtmlProperties,謝謝JLRishe – 2017-02-20 04:59:26