Default Buttons and Wizard Weirdness

J

JJ

I have two related problems:

(a). trying to set the default button within a CreateUserWizard control
-----------------------------------------------------------------

I've done this in a messy way (see below) and wonder if anyone know how I
could have done it using nested FindControl's and ClientID/UniqueID (I tried
jst about every combination!)
The button names you see in the code were obtained by viewing the source of
the html pages. I was hoping I could use something like:

Master.Page.Form.DefaultButton =
Wizard1.ActiveStep.FindControl("CreateUserWizard1").FindControl("btn_CreateUser").UniqueID

- but I just couldn't get this or any combination of it to work. So my
current code to set the deafult button is:

protected void Page_Load(object sender, EventArgs e)
{
Control theButton;
int StepIndex = CreateUserWizard1.ActiveStepIndex;

if (StepIndex == 0)
{
theButton =
this.FindControl("ctl00$MainContent$CreateUserWizard1$__CustomNav0$btn_CreateUserButton");
}
else
{
theButton =
this.FindControl("ctl00$MainContent$CreateUserWizard1$CompleteStepContainer$ContinueButton");
}
Master.Page.Form.DefaultButton = theButton.UniqueID;
}

(b) Detecting when we're at the 'Complete' step
------------------------------------------------

In the above code you'll notice I am checking for the StepIndex. However, I
notice this only changes when the 'Complete' button is clicked on the second
stage!
i.e. after clicking the 'Create User' button on step 1 (StepIndex '0') the
next page appears with my complete step template information and a
'complete' button at the bottom.
yet the StepIndex is still '0'. Only when I click on the 'Continue' button
does it change to '1'.

In which case am I checking the index at the wrong point? How do I detect
when the user is viewing the 'Complete' step?

JJ
 
J

JJ

OK I solved part (b) by doing this(see below) but I am still needing help on
how to correctly set the default button (part (a))

protected void Page_Load(object sender, EventArgs e)
{
SetWizardDefaultButton();
}

protected void OnActiveStepChanged(object sender, EventArgs e)
{
SetWizardDefaultButton();
}


protected void SetWizardDefaultButton()
{
Control theButton;
int StepIndex = CreateUserWizard1.ActiveStepIndex;
if (StepIndex == 0)
{
theButton =
this.FindControl("ctl00$MainContent$CreateUserWizard1$__CustomNav0$btn_CreateUserButton");
}
else
{
theButton =
this.FindControl("ctl00$MainContent$CreateUserWizard1$CompleteStepContainer$ContinueButton");
}

Master.Page.Form.DefaultButton = theButton.UniqueID;
}
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top