Extending ASP.NET DropDownList

2019-07-08 09:43发布

问题:

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?

回答1:

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.



回答2:

Can you extend the capabilities client-side with jQuery?