扩展ASP.NET的DropDownList [英] Extending ASP.NET DropDownList

查看:159
本文介绍了扩展ASP.NET的DropDownList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个从DropDownList中继承的自定义控制。

I am trying to create a custom control that inherits from DropDownList.

我需要的是一个新的属性添加到列表项(项目集内)。

What I need is to add a new property to a ListItem(within Item collection).

<cc1:MyDropDownList ID="MyDropDownList1" runat="server">   
   <asp:ListItem myProperty="true" text="sometext" ... />                     

</cc1: MyDropDownList>

我怎么能这样做?

How can I do that?

推荐答案

即使你从DropDownList的继承,因为你必须将它添加到列表项的控制,你不能添加该属性。

但问题是,一个ListItem类是密封的,所以你不能继承它。

Even if you inherit from the DropDownList you cannot add this property because you have to add it to the ListItem control.
But the problem is that ListItem class is sealed so you cannot inherit from it.

这篇关于扩展ASP.NET的DropDownList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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