Extending ASP.NET DropDownList

2019-07-08 09:34发布

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?

2条回答
太酷不给撩
2楼-- · 2019-07-08 09:59

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.

查看更多
淡お忘
3楼-- · 2019-07-08 10:07

Can you extend the capabilities client-side with jQuery?

查看更多
登录 后发表回答