ASP.Net MVC 2.0:EditorFor通过属性设置名称 [英] ASP.Net MVC 2.0: EditorFor setting name via attributes

查看:174
本文介绍了ASP.Net MVC 2.0:EditorFor通过属性设置名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道我怎么模仿下面使用属性...

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 来保持你的属性,然后我不知道什么是得到它的最好方式,我想你将不得不在此改变 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.

看一下:

为什么你不需要ModelMetadata。属性

ASP.NET MVC 2模板,第2部分:ModelMetadata

这篇关于ASP.Net MVC 2.0:EditorFor通过属性设置名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆