Subclassing Controls

T

TheStripe

Hello all,

Wondering if anyone has come across this problem I am having..

I am Subclassing a RadioButtonList to add some properties that I need. I am
building up
a table and adding to a placeHolder control. I also register an event
handler
just before finally adding MyRadioButtonList to a TableCell control.

On Page_load I call my method that adds a Table containing MyRadioButtonList
to the placeholder.

The strange part is, On the first page load, MyRadioButtonList Selects the
proper ListItem
I have specified in code. on all subsequent postbacks it selects the first
listitem in MyRadioButtonList. I have stepped through the code and
everything seems to be fine. However on the first postback the
SelectedItemChanged event fires, and the first listItem is selected,
Contrary to what I have in code. And all subsequent postbacks have the first
item selected and no event fires.

Any Ideas?

Thanks Guys,
Robert.
 
M

Martin Dechev

Hi, Robert,

First, which methods of RadioButtonList do you override? Then, if you're
changing the values of the RadioButton's, it may be that you are breaking
the logic in the protected method IPostBackDataHandler.LoadPostData and you
will need to override it.

Second, you say:
I also register an event handler
just before finally adding MyRadioButtonList to a TableCell control.

Do you attach to the event on every Page_Load or only when IsPostBack is
false? Maybe this is the problem - you need to subscribe for the event on
every Page_Load.

Greetings
Martin
 
G

Guest

Morning Martin,

I subClassed the control to add a few public propertys that I am using
to pass around added information I need in the Selected Item Changed event.
I did not override any thing in the base class. Thanks for helping figure
this out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top