Question

I have a ASP wizard consisting of four steps ,

  1. Add Customer id

  2. Add ITEM iD.

  3. Add location.

  4. Finalize

I dont want the user to go next without Entering ids and skip any step . I have tried all events and searched a lot but next and previous buttons work as it is .

I also want to finish the option of clickable Side bar hyperlinks.

    if (e.CurrentStepIndex == 1)
    {
        if (LabelCustomerNotify.Text == "notset")
        {
            LabelCustomerNotify.Text = "You can not proceed without selecting customer id";
            Wizard1.ActiveStepIndex = 1;
        }
        else
        {

            Wizard1.ActiveStepIndex++;
        }
    }
    else if (e.CurrentStepIndex == 2)
    {
        if (LabelItemNotify.Text == "notset")
        {
            LabelItemNotify.Text = "You can not proceed without selecting Item id";
            Wizard1.ActiveStepIndex = 1;
        }
        else
        {

            Wizard1.ActiveStepIndex++;
        }
    }
    else if (e.CurrentStepIndex == 3)
    {

        Wizard1.ActiveStepIndex++;
    }

I have entered this code in events like Wizard1_ActiveStepChanged,Wizard1_NextButtonClick etc

Kindly help me

Was it helpful?

Solution

Use the WizardNavigationEventArgs.Cancel property to cancel the move to the next step (in the NextButtonClick event)), rather than your current approach:

if (e.CurrentStepIndex == 1)
{
    if (LabelCustomerNotify.Text == "notset")
    {
        LabelCustomerNotify.Text = "You can not proceed without selecting customer id";
        e.Cancel = true;
    }
}

If it's still not working right, I would run a debugger and make sure that your code is actually entering that if-block. You might just be having an issue with the condition.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top