RadWizard Step validationgroup

5 posts, 0 answers
  1. Kelsey
    Kelsey avatar
    4 posts
    Member since:
    Feb 2015

    Posted 06 Mar 2015 Link to this post

    Hey guys,

    I want to check if the different radwizard steps are valid using their validation group.

    The problem that I am having is since I have RenderedSteps="Active", the other steps are not being shown and I cannot use Page.Validate.

    Example:

    I have four Steps: Step0, Step1, Step2,Step3

    I am currently in step0 and click on the navigation bar to go to Step3

            public void radwizardControl_NavigationBarButtonClick(object sender, Telerik.Web.UI.WizardEventArgs e)
            {
                //We're only going to save information if the user is moving forward, not going back
                if (e.CurrentStepIndex < e.NextStepIndex)
                {

                    for (int iIterator = e.CurrentStepIndex + 1; iIterator < e.NextStepIndex; iIterator++)
                    {
                        Page.Validate(ListOfValidationGroups[iIterator]);
                        if (!Page.IsValid)
                        {
                           radwizardControl.ActiveStepIndex = iIterator;
                            break;
                        }
                    }
               }
           }

    But as I said, the problem lies that when I try to validate a group that isn't rendered, Page.IsValid will always return true.


    Is there any way around this?

  2. Kelsey
    Kelsey avatar
    4 posts
    Member since:
    Feb 2015

    Posted 06 Mar 2015 in reply to Kelsey Link to this post

    Also, if I decide to switch RenderedSteps to "All"

    I then get a problem where if I try to click on a previous step or click the previous button, the validation will occur for the current step and not allow me to go back.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Plamen
    Admin
    Plamen avatar
    2731 posts

    Posted 11 Mar 2015 Link to this post

    Hi,

    Yes indeed it is expected that when the step is not rendered its validation elements will not trigger validation. 

    When you set the RenderedSteps property to "All" you workaround the default behavior that does not allow going back by using the following code:
    function OnClientButtonClicking(sender, args) {
     
                  if (sender.get_activeIndex() > args.get_nextActiveStep().get_index()) {
                      args.set_cancel(true);
                      sender.set_activeIndex(args.get_nextActiveStep().get_index());
                  }
              }

    Hope this will help you solve the issue.

    Regards,
    Plamen
    Telerik
  5. Gidon
    Gidon avatar
    7 posts
    Member since:
    Apr 2014

    Posted 11 Apr in reply to Plamen Link to this post

    sender.set_activeIndex() seems to trigger validation as of 2016Q1. Like the OP, I have a RadWizard with 4 individually validated steps. I want to allow users to step backwards no matter what. I only want them to be able to step forward if the current page passes validation. Using RenderedSteps="All" and the above JavaScript OnClientButtonClicking, I still can't click either the Previous button or the entries for previous steps in the navigation bar. In both cases validation triggers and my 'required' messages appear but the active step does not change. I even tried manually triggering $find("RadWizardClientID").set_activeIndex(0); in the browser's JavaScript console only to have validation trigger and the active step remain the same. 

    I've gotta say, compared to the standard ASP.NET Wizard, the RadWizard is a complete pain in the butt when it comes to validation. I can't for the life of me figure out when I'd want this thing to validate more than 1 step at a time, or when I'd want it to prevent me from accessing a previous step due to the current step's validation results.

  6. Plamen
    Admin
    Plamen avatar
    2731 posts

    Posted 14 Apr Link to this post

    Hi,

    Here is the code that worked correctly at my side for the desired scenario- " I want to allow users to step backwards no matter what. I only want them to be able to step forward if the current page passes validation":
    <telerik:RadWizard runat="server" ID="RadWizard2" RenderedSteps="All">
               <WizardSteps>
                   <telerik:RadWizardStep ID="RadWizardStep3" ValidationGroup="Group1"  >
     
                       <asp:TextBox runat="server" ID="TextBox1" ValidationGroup="Group1" />
                       <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="ADD TEXT"
                           ControlToValidate="TextBox1" ValidationGroup="Group1">
                       </asp:RequiredFieldValidator>
                   </telerik:RadWizardStep>
                  <telerik:RadWizardStep ID="RadWizardStep1" ValidationGroup="Group2">
     
                       <asp:TextBox runat="server" ID="TextBox2" ValidationGroup="Group2" />
                       <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="ADD TEXT"
                           ControlToValidate="TextBox2" ValidationGroup="Group2">
                       </asp:RequiredFieldValidator>
                   </telerik:RadWizardStep>
                     <telerik:RadWizardStep ID="RadWizardStep2" ValidationGroup="Group3">
     
                       <asp:TextBox runat="server" ID="TextBox3" ValidationGroup="Group3" />
                       <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="ADD TEXT"
                           ControlToValidate="TextBox3" ValidationGroup="Group3">
                       </asp:RequiredFieldValidator>
                   </telerik:RadWizardStep>
                
               </WizardSteps>
           </telerik:RadWizard>


    Regards,
    Plamen
    Telerik
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017