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

RadWizard Step validationgroup

4 Answers 324 Views
Wizard
This is a migrated thread and some comments may be shown as answers.
Kelsey
Top achievements
Rank 1
Kelsey asked on 06 Mar 2015, 03:27 PM
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?

4 Answers, 1 is accepted

Sort by
0
Kelsey
Top achievements
Rank 1
answered on 06 Mar 2015, 05:06 PM
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.
0
Plamen
Telerik team
answered on 11 Mar 2015, 06:46 AM
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
0
Gidon
Top achievements
Rank 1
answered on 11 Apr 2016, 04:48 PM

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 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.

0
Plamen
Telerik team
answered on 14 Apr 2016, 07:00 AM
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
Tags
Wizard
Asked by
Kelsey
Top achievements
Rank 1
Answers by
Kelsey
Top achievements
Rank 1
Plamen
Telerik team
Gidon
Top achievements
Rank 1
Share this question
or