ASP.Net/Validation by Control/BaseValidator — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 18:30, 26 мая 2010
as BaseValidator
<source lang="csharp">
<%@ Page Language="vb" %> <html>
<head> <title>Validators collection example</title> <script runat="server"> Sub Page_Load() Dim Validator as BaseValidator For Each Validator in Validators Message.Text &= Validator.ID & " error message: " Message.Text &= Validator.ErrorMessage & "
" Next End Sub </script> </head>
<body>
<form runat="server"> Phone: <asp:textbox id="phone" runat="server"/> <asp:requiredfieldvalidator id="rfvPhone" controltovalidate="phone" display="dynamic" errormessage="Required!" runat="server"/> <asp:regularexpressionvalidator id="revPhone" controltovalidate="phone" display="dynamic" validationexpression="^[2-9]\d{2}-\d{3}-\d{4}$" errormessage="Enter a valid phone number in the form xxx-xxx-xxxx" runat="server"/>
<asp:button id="submit" text="Submit" runat="server"/> </form>
<asp:label id="Message" runat="server"/>
</body> </html>
</source>