views:

262

answers:

3

A web app our group has put together uses the ASP.NET Wizard control. Each step in the wizard contains a corresponding custom UserControl.

The trouble is that as you go through the wizard steps, all the UserControls are loaded on each step, rather than just the one used in that step. That doesn't seem right to me.

So...is there anybody here that's done a lot of work with the Wizard control and can give some guidelines on how to use it correctly, and keep it from loading way too much junk with each step?

+1  A: 

One thing that could help you a bit is not putting any code in your UserControls's Page_Load function but instead putting that same code in it's Page_PreRender. That's crucial when using a MultiView and probably applies to the wizard as well.

mspmsp
A: 

mspmsp has a good recommendation about PreRender, another option that I have noticed used before is to simply move all configuration code inside the control to a ConfigureControl method.

Then when switching views, you can call the ConfigureControl() method to explicitly create/load your control. It has the same purpose, but it helps make the code a bit easier to understand in my opinion.

Mitchel Sellers
A: 

FYI, (at least part of) the reason it loads all user controls on each step is so that you can access the values entered on other steps. If it didn't load the controls, you couldn't easily make decisions about the current step based on what was entered in a previous step (e.g. filtering a list based on a selection in a previous step).

Eddie Deyo