问题描述
只是想知道我怎么模仿下面使用属性...
Just wondering how do I mimic the following using attributes...
<%= Html.EditorFor(x => x.SportProgramIdList, "FormMultiSelectDropDownList", "SportProgramIds")%>
我知道我可以用[UIHint(FormMultiSelectDropDownList)指定的模板,但我留下着如何设置名称的问题...
I know I can specify the template by using [UIHint("FormMultiSelectDropDownList")] but I am left with the problem with how to set the name...
干杯安东尼
推荐答案
我想你必须创建自己的CustomAttribute UINameAttribute
。您可以使用 ModelMetadata code>来保持你的属性,然后我不知道什么是得到它的最好方式,我想你将不得不在此改变
HtmlHelper.EditorFor
拓没有参数,你的属性传递到下一个。
I Guess you'll have to create your own CustomAttribute UINameAttribute
.You could use the ModelMetadata
to keep your attribute and then I'm not sure what would be the best way to get it, i guess you would have to overide the HtmlHelper.EditorFor
Extension without the parameter and pass your attribute to the next.
我懒得和疲惫去尝试一个更完整的答案。
I'm too lazy and to tired to try for a more complete answer.
看一下:
ASP.NET MVC 2模板,第2部分:ModelMetadata A>
这篇关于ASP.Net MVC 2.0:EditorFor通过属性设置名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!