I ran into a rather unfortunate issue today with a server control that I
thought would probably be good to talk about. The issue is created by non-bugs
that come together to make a bug.
-
Firefox persists the values of form fields when the user refreshes
the page.
-
Firefox does not persist any script objects applied to the document or the
window
-
Complex server controls will commonly use script objects for the lifetime of
the page, and use hidden inputs to round trip values from server to client to
server.
So this is the result of these 3 items...
-
A user with firefox hits your page with your control on it the first time...
-
Your initialization script runs, and all script objects and hidden inputs are
in the initialized state.
-
The user plays with the page a bit, and your control changes its state,
changing object properties and hidden input values.
-
The user hits refresh in their browser. Firefox nullifies all script objects,
but retains the values of the hidden inputs.
-
Your control's initialization runs again, but now the script objects are
created with hidden input state that is not the original.
Now, as you can imagine, this has a very high possibility of completely borking
your control. Now, before I get flames, let me restate that I don't consider
this a bug in Firefox. It's just a behavior that I hadn't planned for. However,
ultimately, it has a way of changing my methods for roundtripping values
between client and server.
For now, my best solution is to include any "initial" values in the
RegisterArrayDeclaration call for the control, while previously i would
normally only put them in the hidden input.