Data Validation Tools in ToolBox of VS are shown Below:
RequireFieldValidator and ValidationSummary
Source Code on aspx page :
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please Enter Name" ControlToValidate="TextBox1" ToolTip="Name Required">*</asp:RequiredFieldValidator>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" />
<asp:Button ID="Button1" runat="server" style="text-align: right" Text="Button" /gt;
Design View of above code:
Properties Window of RequireFieldValidator and ValidationSummary:
View in Browser : If you press button Without enter name in Textbox then Message box and Text Message will be shown to show Error. Here * represented the RequireFieldValidator.
Date of Birth validation Using RequireFieldValidator,RegularExpressionValidator and RangeValidator
default.aspx code(click image to enlarge)
default.aspx.cs code
Design View of above code:
Properties Window of RequireFieldValidator, RegularExpressionValidator and RangeValidator:
RequireFieldValidator Properties |
Email validation Using RequireFieldValidator, RegularExpressionValidator
Source code:(click image to enlarge)
Design View:
RegularExpressionValidator Properties | RequireFieldValidator Properties |
Password validation Using RequireFieldValidator, RegularExpressionValidator, CustomValidator and Compare Validator
default.aspx code(click image to enlarge)
default.aspx.cs code
Design View:
RequireFieldValidator Properties for Password | RegularExpressionValidator Properties for password |
CustomValidator Properties for password | RequireFieldValidator Properties for Re-Enter Password |
Compare Validator Properties for Re-Enter Password |
No comments:
Post a Comment