Each validation control performs a specific type of validation (like validating against a specific value or a range of values).
By default, page validation is performed when a Button, ImageButton, or LinkButton control is clicked. You can prevent validation when a button control is clicked by setting the CausesValidation property to false.
The syntax for creating a Validation server control is:
< asp:control_name id="some_id" runat="server" />
Example
< html>
< body>
< form runat="server">
< p>Enter a number from 1 to 100:
< asp:TextBox id="tbox1" runat="server" />
< br /><br />
< asp:Button Text="Submit" runat="server" />
< /p>
< p>
< asp:RangeValidator
ControlToValidate="tbox1"
MinimumValue="1"
MaximumValue="100"
Type="Integer"
Text="The value must be from 1 to 100!"
runat="server" />
< /p>
< /form>
< /body>
< /html>
< body>
< form runat="server">
< p>Enter a number from 1 to 100:
< asp:TextBox id="tbox1" runat="server" />
< br /><br />
< asp:Button Text="Submit" runat="server" />
< /p>
< p>
< asp:RangeValidator
ControlToValidate="tbox1"
MinimumValue="1"
MaximumValue="100"
Type="Integer"
Text="The value must be from 1 to 100!"
runat="server" />
< /p>
< /form>
< /body>
< /html>
No comments:
Post a Comment