Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Idiotic ASP.NET problem

I have a header user control on my page and this has a search box and a radio button list with the first button checked by default.

When I enter something in the search box and click the 'go' button, everything is fine - i.e. the code behind recognizes that the first one is checked and does something.

Now if I click the second button and click 'go', everything is fine - it works like I want, but the troubles begin here. When the page reloads, the second button is no longer checked - as if the view state was never saved. Not just that, now when I click the first rb and click 'go', my code behind still thinks the second button is checked!

It's driving me crazy, what am I missing here?

duh
Friday, May 06, 2005

It may be that the event handler for the radio button check events are firing after the page load events. That's why after selecting radio button2 and submittibng the form it thinks radio button 1 is checked, and then clicking radio button 1 and submitting and it thinks radio button 2 is checked. If you continue this pattern, you'll see that the viewstate if off by one  (or 'behind by one'?). So, check the order iof events in the debugger is you are using vs.net, or response.write.

Hash550
Saturday, May 07, 2005

Do you have more than one Form tag?  I'm not positive but I beleive each form tag gets it's own __viewstate hidden text box.  If that's the case then only the state of the controls in the form will be posted back to the server.

ian
Tuesday, May 10, 2005

*  Recent Topics

*  Fog Creek Home