如何建立自定义属性? [英] how can buid a custom attribute?

查看:78
本文介绍了如何建立自定义属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的选择框的自定义属性是什么,这个属性有一个属性是listItem,如何将数据值加载到listitem的属性?

I what buid a custom attribute of select box,this attribute has a property is "listItem",how can
to load data value to the property of listitem?

推荐答案

有关为MVC编写自定义属性的帮助,请通过 -



在MVC 3中创建自定义验证属性 [ ^ ]

http://www.dotnetcurry.com/ShowArticle.aspx?ID=687 [ ^ ]

http://www.diaryofaninja.com/blog/2011/07/24/writing-your-自有铜stom-aspnet-mvc-authorize-attributes [ ^ ]
For help on writing custom attributes for MVC, go through -

Creating Custom Validation Attribute in MVC 3[^]
http://www.dotnetcurry.com/ShowArticle.aspx?ID=687[^]
http://www.diaryofaninja.com/blog/2011/07/24/writing-your-own-custom-aspnet-mvc-authorize-attributes[^]


<select>
<option value="1" data-value="myValue1">item</option>
<option value="2" data-value="myValue2">item</option>
<option value="3" data-value="myValue3">item</option>
</select>










<select id="selectList" class="multiselect" multiple="true" name="selectList[]" runat="server">&lt;/select>







ListItemCollection values = new ListItemCollection();
ListItem test = new ListItem("add");
test.Attributes.Add("data-value", "myValue");
values.Add(test);
this.selectList.DataSource = values;
this.selectList.DataBind();


这篇关于如何建立自定义属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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