Validating Information Before a Tab Page Switch
TabControl for ASP.NET AJAX allows you to perform validation checks before tab page switches take place. To illustrate this feature, this topic will show you how to set up a C1TabControl control so that a tab page switch cannot be performed without text being entered into a standard TextBox control.
Complete the following steps:
1. Click
C1TabControl's smart tag () to open the C1TabControl Tasks menu and then select
TabControl Designer.
The C1TabControl Designer Form appears.
2. Use the Add Child
Item button to add two C1TabPages
to your C1TabControl.
3. With C1TabControl1 selected in treeview, set the following properties:
• Set the CausesValidation property to True.
• Set the ValidationGroup property to "PasswordValidation".
4. Click OK to close the C1TabControl Designer Form.
5. Add a standard TextBox control to C1TabPage1 and set its ID property to "PasswordBox".
6. Add a RequiredFieldValidator control to C1TabPage1, placing it beneath the TextBox control that you added in the last step. Set its properties as follows:
• Set the ControlToValidate property to PasswordBox.
• Set the ValidationGroup property to "PasswordValidation".
• Set the Text property to "You must enter text before proceeding".
7. Run the project.
This Topic Illustrates the Following:
Once the project is built, click on C1TabPage2 without typing anything into the text box. The result will resemble the following image:
Now enter text into the text box and click C1TabPage2 again.
Observe that C1TabPage2 comes into focus without throwing an error.
|