This is driving me nuts. I've reviewed and tried answers from these SO threads, to no avail:
CreateUserWizard step changing issue after account creation
Advancing wizard from code-behind in ASP.NET
Prevent Navigation to CreateUserWizardStep in the Postback event of nextbutton
I have added a wizardstep before the one that creates the user on the database:
(0) Personal Details
(1) Sign Up for Your New Account
(2) Complete
In step 0, I have a (dreaded) reCaptcha. Navigation template for step 0:
<StartNavigationTemplate>
<asp:Button ID="StartNextButton" runat="server" CommandName="MoveNext" Text="Next" OnClick="StartNextButton_Click" CausesValidation="true"/>
</StartNavigationTemplate>
Here, I validate the reCaptcha in the codebehind. This handler declaration was created by VS2012. If the validation fails, should re-load (and navigate to) the step:
protected void StartNextButton_Click(object sender, EventArgs e)
{
recaptcha.Validate();
if (! recaptcha.IsValid)
{
RegisterUser.ActiveStepIndex = 0;
RegisterUser.MoveTo(RegisterUser.ActiveStep);
}
}
Ideally ( and what I've done in earlier versions ) is to set e.Cancel = true when validation fails. Since VS is only passing EventArgs e, Cancel isn't available, thus the twiddling of ActiveStep.
Debugging shows validation is working, but on validation failure - despite setting the ActiveStepIndex to 0 - I'm passed to Step 1.
Any tips would be appreciated.