I am working with CreateUserWizard tool for creating a registration page. This is the first time and I am encountering problem with the following:
I defined two steps in WizardSteps in the page:
<WizardSteps>
<asp:WizardStep ID="CreateUserWizardStep0" runat="server" Title="Sign Up for your new Account !!">
<asp:TextBox ID="Email" runat="server">
In the first wizard step, the user provides email, and we need to check if this email meets certain criteria (if he exists in our internal database, country is US etc) and if he/she is eligible navigate to CreateUserWizardStep1.
I have a StartNextButton in the Start Navigation template for the WizardStep0.
<StartNavigationTemplate>
<br />
<asp:Button ID="StartNextButton" runat="server" CommandName="MoveNext" OnClick="StartNextButton_Click"
Text="Check My Eligibility" />
</StartNavigationTemplate>
I do all the logic of checking eligibility in the post-back event OnClick="StartNextButton_Click
. If he is not eligible, I should display the error message in the step0 textbox and prevent navigation to CreateUserWizardStep1.
I tried the following:
if(noteligible)
{
lblError1.Visible = true;
lblError1.Text = this.hfUserAlreadyRegistered.Value.ToString();
this.CreateUserWizard1.ActiveStepIndex = this.CreateUserWizard1.WizardSteps.IndexOf(this.CreateUserWizardStep0);
this.CreateUserWizard1.Controls.Remove(CreateUserWizardStep1);
this.CreateUserWizard1.ActiveStepIndex = 0;
break;
}
But this is not working. I am taken out of step0 and step1 is coming irrespective of this.
How can I just remain in Step0 and display the error message when the user is not eligible and navigate to Step1 only when he is eligible to register ?
Thank you very much.