That works fine: if the user hits enter on a control within a wizard it goes to the next page.
However surround the Wizard with an UpdatePanel and it only works once on the first page of the wizard. After that it does the somewhat annoying thing of firing the first button on the page's click. In my case this is a home linkbutton so the user gets booted
out of the wizard and sent back to the home page!
Mad Pierre
Member
4 Points
7 Posts
Default Button in Wizard with Ajax
Feb 17, 2012 11:07 AM|LINK
In a Wizard you can set the DefaultButton property like so:
private void SetDefaultButton(int StepIndex) { if (StepIndex == 0) //1st Step Page.Form.DefaultButton = Wizard1.FindControl("StartNavigationTemplateContainerID$StartNextButton").UniqueID; else if (StepIndex == Wizard1.WizardSteps.Count - 1) //Last step Page.Form.DefaultButton = Wizard1.FindControl("FinishNavigationTemplateContainerID$FinishButton").UniqueID; else //middle step Page.Form.DefaultButton = Wizard1.FindControl("StepNavigationTemplateContainerID$StepNextButton").UniqueID; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); //Start off with correct default button if (!Page.IsPostBack) SetDefaultButton(0); } protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e) { SetDefaultButton(e.CurrentStepIndex + 1); } protected void Wizard1_PreviousButtonClick(object sender, WizardNavigationEventArgs e) { SetDefaultButton(e.CurrentStepIndex - 1); }That works fine: if the user hits enter on a control within a wizard it goes to the next page.
However surround the Wizard with an UpdatePanel and it only works once on the first page of the wizard. After that it does the somewhat annoying thing of firing the first button on the page's click. In my case this is a home linkbutton so the user gets booted out of the wizard and sent back to the home page!
I am not the first person to come up against this. I've tried the work arounds suggested here: http://stackoverflow.com/questions/1200989/setting-default-button-in-ajaxified-wizard-control without any joy.
Anyone help? This one is wasting much of my life!