How to cancel step change in code-behind

3 posts, 1 answers
  1. Al
    Al avatar
    203 posts
    Member since:
    Oct 2006

    Posted 29 May 2015 Link to this post

    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. Answer
    Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 29 May 2015 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Al
    Al avatar
    203 posts
    Member since:
    Oct 2006

    Posted 01 Jun 2015 in reply to Ivan Danchev Link to this post

    I seem to recall that I had some trouble setting ActiveStepIndex server-side but using the client event worked just fine.
Back to Top