tags:

views:

354

answers:

3

I'm creating a multi-part web form in ASP.NET that uses Panels for the different steps, making only the Panel for the current step visible. On Step 1, I have a drop-down list that uses a Javascript function to reconfigure some of the fields in the same Panel via "onchange". Obviously, since the client-side script is only affecting the DOM, when I go to Step 2 and then back up to Step 1, the fields in Step 1 are back to their orignal configuration even though the same drop-down choice is selected.

What is a good method for storing the visual state of the Panels between steps? I considered calling the drop-down's onchange function on page load, but that seemed clunky. Thanks!

--

Thanks for the quick answers - I think I'll try out the Wizard, but the AJAX solution also sounds like fun.

+1  A: 

You might consider an ASP.Net Wizard control for this- it will automate a lot of what you're trying to do.

Joel Coehoorn
+1  A: 

I suggest you to use the MultiView control, which is let's say semantically more appropiate. And then store this data in ViewState. I have written something similar and it rocks.

netadictos
+1  A: 

I think your best bet is to maintain all of your state in one place, or don't maintain any state at all. The main problem you're having is synchronizing your client-side state with your server-side state.

Try showing/hiding your panels with javascript instead of posting back, if possible. If not, use some ajax to update values on the server-side as soon as they are selected, rather than when you click the next/previous button.

Otherwise, you could use something like ASP.Net Ajax Toolkit Tabs to help with transitions.

Hope that helps!

Zachary Yates
Ajax is great, but remember this is not accessible, that is to say, that screen readers will not read the form, it depends on the exigences of your customer that you have to take this in mind.
netadictos
Good point. Good word too. ^^
Zachary Yates