Validate wizard data against database

sglew used Ask the Experts™

I'm working on setting up a web page with a wizard control and I have it laid out the way I want it to be and now I'm going back and trying to add the data validation.  The very first step in the process is one where a person enters a given promo code and before they move onto the next step I need to be able to verify that 1) the code is valid and 2) the code hasn't already been used.  I have the proper code built into my Wizard1_StartNextButtonClick routine to verify the data but I'm not exactly sure how to set the process up to revert back to first step when an error is found in the code.

What currently happens when I hit the next button is that it goes to the next step even though the code is incorrect or has already been used.  I can verify that much by clicking on the left navigation of the Wizard to get back to the first step and see that my error label is populated with the error message.  As you can see in my if statement I tried to set the "ActiveStepIndex" back to zero but it still moves to the next step.

Is there something I am missing when it comes to validating data entered?  Should I use a different method to validate this data?

If codecount = 0 then
    Wizard1.ActiveStepIndex = 0
    lblCodeError.Text = "The code you entered is invalid, please double check your code and try again."
ElseIf codecountUsed = 1
    Wizard1.ActiveStepIndex = 0
    lblCodeError.Text = "The code you entered has already been used. You can only use your code once."
End If

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Robb HillSenior .Net Full Stack Developer

each step of the wizard control is most likely making a forceback..and you are validating ..client you have to validate this client for this purpose....

If not..just redirect on the command event of this control...setting this index value.

if not the client side part of your validator may need to be a custom validator with jscript that handles this paging through the wizard as validation occurs.  YOu have to take into account the view state of a control when validation events are triggered and then what they are once validation is over.
I ended up adding a step to my process and that step houses a label with my error messages and if they type in an ivalid code the customer is directed to this step with only a "Previous" button on it, otherwise they are sent to the next proper step in the process.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial