This is a migrated thread and some comments may be shown as answers.

How to cancel step change in code-behind

2 Answers 191 Views
Wizard
This is a migrated thread and some comments may be shown as answers.
Al
Top achievements
Rank 1
Iron
Iron
Iron
Al asked on 29 May 2015, 01:32 PM

Hi,

If the user clicks next, is there a way to cancel the move to the next tab in ActiveStepChange?  or even just to set the active step back to the previous step.

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Danchev
Telerik team
answered on 29 May 2015, 03:02 PM
Hello,

Thank you for contacting Telerik Support.

1. The ActiveStepChanged event is a server event and cannot be canceled, however, the ActiveStep can be changed to the previous one as demonstrated in the following code snippet:
protected void RadWizard1_ActiveStepChanged(object sender, EventArgs e)
{
    int activeStepIndex = (sender as RadWizard).ActiveStep.Index;
    (sender as RadWizard).ActiveStepIndex = activeStepIndex - 1;
}

2. Here's how you can cancel the navigation to the next step on the client, when the user clicks on the "Next" button:
function OnClientButtonClicking(sender, args) {
    //additional logic/condition for canceling the event
    var command = args.get_command();
    if (command == "1") {
        args.set_cancel(true);
    }       
}

The buttons are associated with different commands codes and the command for the "Next" button is "1". You can get this data in the OnClientButtonClicking event handler and cancel the event. Additional logic may be added in order to cancel the event only when the user clicks "Next" in a particular step. 

I hope this was useful. Feel free to contact us again if you have more questions.

Regards,
Ivan Danchev
Telerik
0
Al
Top achievements
Rank 1
Iron
Iron
Iron
answered on 01 Jun 2015, 11:50 AM
I seem to recall that I had some trouble setting ActiveStepIndex server-side but using the client event worked just fine.
Tags
Wizard
Asked by
Al
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Ivan Danchev
Telerik team
Al
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or