I have a custom control which has a RadioButtonList control in it. On selecting one of the radio buttons , the control does a postback to do some serverside work and the page reloads with the correct radiobutton selected. This works fine in my test page.
I’ve now moved the control into a page on the site it’s going to live in and when the radiobutton is selected, the postback occurs but when the page reloads the radiobutton is no longer selected. So it appears the the selection is no longer being saved into viewstate.
Any pointers as to what aspects of the new page I should be looking at would be very gratefully received.
Cheers
Adendum – a bit more info
Thanks for the advice Stephen
The control was originally developed as a web user control using the designer, very simple implementation , server side handlers for onload and when the radiobutton selection changes. Separate dll for code behind and an ascx. I then converted it to a custom control to pull the ascx into the dll with the compiled code behind.
I don’t dynamically create the control in the test page, there’s a tag and a <%@ Register …blah blah> at the top in the aspx to do that. The radiobuttonlist was dragged and dropped in the ascx using the designer, so I didn’t implement the code to create it. So all very vanilla.
I’m really looking for the differences that I should be looking at in the pages that use the control, to work out why it works in the test page but not in the site page it needs to reside in.
*********** Addition ***********
I had a short time to solve this problem and had to hand it over to another developer. When I find out from him what the solution was I’ll post it here.
Many thanks to all for their input.
*********** Answer *************
Here’s the answer from the developer that took over.
Your quiz control was fine mate, the reason the values weren’t being retained on postback was because of inherited functionality in the base class when you put it live. Essentially it did a DataBind in the page load method which in the page lifecycle is before the postback meethods get called, so it reset the values of the dropdowns. In the end I set up some viewstate properties which held the values of the dropdowns. So it wasn’t something you could have known about.
Got a response from the developer that took over the project ->
“Your quiz control was fine mate, the reason the values weren’t being retained on postback was because of inherited functionality in the base class when you put it live. Essentially it did a DataBind in the page load method which in the page lifecycle is before the postback meethods get called, so it reset the values of the dropdowns. In the end I set up some viewstate properties which held the values of the dropdowns. So it wasn’t something you could have known about.”
Hope this helps someone.