Wizard control and postbacks

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Wizard control with each step using a user control. It seems the
page_load of each user control is called everytime a postback event occurs in
any step. Is there away to communicate to a user control that is it now the
current "page" so I can restrict some of the initialization to occur only
when the step is visible? I have a couple of controls that hit the database
and don't want the overhead if the use isn't even looking at that Wizard step.

Thanks for any hints on this.
 
if you want code to run only on first page load check the IsPostBack
property of the page, like this:

protected void Page_Load(object sender, EventArgs e)
{
if(Page.IsPostBack)
{
//code gets run only on postback
}
else
{
//code gets run only on initial load
}
}
 
I may be green, but not quite that green ;)

Because the data I'm retrieving isn't saved in the viewstate and the
Calendar control needs it everytime it renders from a selectionChanged or
other event I'm reloading the data in that user controls PageLoad event,
postback or not. What I was hoping to do was not load it if the user control
is on a different Wizard step than the one currently being show.

Thanks!
 
ah, sorry, didn't read it thoroughly enough :)

in Page_Load of the control, you can get a reference to the containing
wizard step like this:

WizardStep step = (WizardStep)this.Parent;

you can get a reference to the Wizard like this:

Wizard wizard = step.Wizard

play with wizard.ActiveStep and .ActiveStepIndex to see if you can do
what you want

cheers

nm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top