Domanda

I have a number of textboxes as the first step in my wizard.

All these textboxes have a requiredfieldvalidator on them.

I need to find a way to bypass these validations or ignore them for the time being because i need to display all the error at the end of the wizard as a last step before clicking on finish.

The problem i have is that the wizard does not allow me to navigate to the next step untill all the textboxes have been filled in.

Is there a way i can ignore the errors and navigate on in my wizard and use them in a validation summary at the end of my wizard?

here is my asp code: (i have tried setting each textboxes CausesValidation to false but this still does not work)

            <asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1 - Customer Information">

                <asp:Table runat="server" ID="UserInfoTable">

                    <asp:TableRow>
                        <asp:TableCell>
                            <asp:Label ID="Label2" runat="server" Text="Identification Number:"></asp:Label>&nbsp&nbsp
                        </asp:TableCell>

                        <asp:TableCell>
                            <asp:TextBox runat="server" ID="txtUserID" CausesValidation="false"></asp:TextBox>
                            <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator" ErrorMessage="*Required" ControlToValidate="txtUserID"></asp:RequiredFieldValidator><br />
                        </asp:TableCell>
                        </asp:TableRow>

                    <asp:TableRow>
                        <asp:TableCell>
                            <asp:Label ID="Label1" runat="server" Text="First Name:" CausesValidation="false"></asp:Label>&nbsp&nbsp
                        </asp:TableCell>

                        <asp:TableCell>
                            <asp:TextBox runat="server" ID="txtUserFName" CausesValidation="false"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*Required" ControlToValidate="txtUserFName"></asp:RequiredFieldValidator><br />
                        </asp:TableCell>                   
                    </asp:TableRow>

                    <asp:TableRow>
                        <asp:TableCell>
                            <asp:Label ID="Label3" runat="server" Text="Second Name:" CausesValidation="false"></asp:Label>&nbsp&nbsp
                        </asp:TableCell>
                        <asp:TableCell>
                            <asp:TextBox runat="server" ID="txtUserSurname"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*Required" ControlToValidate="txtUserSurname"></asp:RequiredFieldValidator><br />
                        </asp:TableCell>
                    </asp:TableRow>

                    <asp:TableRow>
                        <asp:TableCell>
                            <asp:Label ID="Label4" runat="server" Text="Street Addrress:" CausesValidation="false"></asp:Label>&nbsp&nbsp
                        </asp:TableCell>
                        <asp:TableCell>
                            <asp:TextBox runat="server" ID="txtUserAddress" CausesValidation="false"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="*Required" ControlToValidate="txtUserAddress"></asp:RequiredFieldValidator><br />
                        </asp:TableCell>
                    </asp:TableRow>

                    <asp:TableRow>
                        <asp:TableCell>
                            <asp:Label ID="Label5" runat="server" Text="City:" CausesValidation="false"></asp:Label>&nbsp&nbsp
                        </asp:TableCell>
                        <asp:TableCell>
                            <asp:TextBox runat="server" ID="txtUserCity"></asp:TextBox>

                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="*Required" ControlToValidate="txtUserCity"></asp:RequiredFieldValidator><br />
                        </asp:TableCell>
                    </asp:TableRow>

                    <asp:TableRow>
                        <asp:TableCell>
                            <asp:Label ID="Label6" runat="server" Text="E-Mail:" CausesValidation="false"></asp:Label>&nbsp&nbsp
                        </asp:TableCell>
                        <asp:TableCell>
                            <asp:TextBox runat="server" ID="txtUserEmail"></asp:TextBox>

                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="*Email address incorrect" ControlToValidate="txtUserEmail" ValidationExpression=".+@.+"></asp:RegularExpressionValidator><br />

                        </asp:TableCell>
                    </asp:TableRow>

                    <asp:TableRow>
                        <asp:TableCell>
                            <asp:Label ID="Label7" runat="server" Text="Contact Number:" CausesValidation="false"></asp:Label>&nbsp&nbsp
                        </asp:TableCell>
                        <asp:TableCell>
                            <asp:TextBox runat="server" ID="txtContactNo"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="*Required" ControlToValidate="txtContactNo"></asp:RequiredFieldValidator>


                            <br />
                        </asp:TableCell>
                    </asp:TableRow> 

                </asp:Table>
            </asp:WizardStep>

I know how to use the validation summary. So i dont need help with that.. I just need to know how to disable the validation on the controls.

Thank you for your help.

È stato utile?

Soluzione

Sorted the problem out..

The solution is to move all the validators to the last step of the wizard.

here is my code as an example:

        <asp:WizardStep ID="WizardStep4" runat="server" Title="Step 4 - Finalize booking">
            <h2>Finish</h2>
                <asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="Errors"/>


            <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator7" ErrorMessage="Customer ID required" ControlToValidate="txtUserID" Font-Bold="true" ForeColor="Red" Display="None"></asp:RequiredFieldValidator><br />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ErrorMessage="Customer first name required" ControlToValidate="txtUserFName" Font-Bold="true" ForeColor="Red" Display="None"></asp:RequiredFieldValidator><br />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ErrorMessage="Customer last name required" ControlToValidate="txtUserSurname" Font-Bold="true" ForeColor="Red" Display="None"></asp:RequiredFieldValidator><br />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator10" runat="server" ErrorMessage="Customer address required" ControlToValidate="txtUserAddress" Font-Bold="true" ForeColor="Red" Display="None"></asp:RequiredFieldValidator><br />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ErrorMessage="Customer city required" ControlToValidate="txtUserCity" Font-Bold="true" ForeColor="Red" Display="None"></asp:RequiredFieldValidator><br />
            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Email format is incorrect" ControlToValidate="txtUserEmail" ValidationExpression=".+@.+" Font-Bold="true" ForeColor="Red" Display="None"></asp:RegularExpressionValidator><br />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator12" runat="server" ErrorMessage="Contact number incorrect" ControlToValidate="txtContactNo" Font-Bold="true" ForeColor="Red" Display="None"></asp:RequiredFieldValidator>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ErrorMessage="Enter number of people for booking" Font-Bold="true" ForeColor="Red" ControlToValidate="txtNoOfPeople" Display="None"></asp:RequiredFieldValidator>

            </asp:WizardStep>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top