views:

31

answers:

3

I am working on to create a custom control inherited by CheckboxList control. We can add items from ListItem collection editior at the design time. In this ListItem Collection editor there are 4 properties
1) Enabled
2) Selected
3) Text
4) value

I really need to add some new properties such as "ImageURL" and "IsClear". Do you have any ideas/methods or magic to add these properties.

I need Expert's opinion from StackOverFlow.com

Thanks

A: 

Hey,

You can create a class that inherits from ListItem to add the properties. But inheriting from CheckBoxList would use the ListItem base type... You could try shadowing the Items collection to use your custom type, though I don't know that will work the same way... it depends where you need to use these new properties of the list item.

HTH.

Brian
Thanks for your quick reply
Kamlesh
A: 

Have you considered creating a User Control? You can define public members in the code behind that will then be accessible when you define the control on you aspx page.

Your aspx page would have something like this:

<%@ Register Assembly="MyCustomControls" Namespace="MyCustomControls" TagPrefix="cust" %>
...
<cust:MyCheckBoxList ID="cbl" runat="server" imageURL="http://blah.com/1.jpg" isClear="false />
Abe Miessler
A: 

The ListItem class has the Attributes property. Use it. You'll find there any additional attributes specified for asp:listitem in the mark-up that are not mapped to the properties.

thorn