compare5.aspx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <%@ Page Language="C#" AutoEventWireup="True" %>
  2. <html>
  3. <head>
  4. <script runat="server">
  5. void ValidateBtn_Click(Object sender, EventArgs e)
  6. {
  7. if (Page.IsValid)
  8. {
  9. lblOutput.Text = "Page is Valid!";
  10. }
  11. else
  12. {
  13. lblOutput.Text = "Page is InValid! :-(";
  14. }
  15. }
  16. </script>
  17. </head>
  18. <body>
  19. <h3>RegularExpressionValidator Example</h3>
  20. <p>
  21. <form runat="server">
  22. <table bgcolor="#eeeeee" cellpadding="10">
  23. <tr valign="top">
  24. <td colspan="3">
  25. <asp:Label ID="lblOutput"
  26. Text="Enter a number greater than 50"
  27. runat="server"/>
  28. </td>
  29. </tr>
  30. <tr>
  31. <td colspan="3">
  32. <b>Information</b>
  33. </td>
  34. </tr>
  35. <tr>
  36. <td align="right">
  37. Value:
  38. </td>
  39. <td>
  40. <asp:TextBox id="TextBox1"
  41. runat="server"/>
  42. </td>
  43. <td>
  44. <asp:CompareValidator id="CompareValidator1"
  45. ControlToValidate="TextBox1"
  46. Operator="greaterthan"
  47. Type="Integer"
  48. ValueToCompare="xx"
  49. Display="Static"
  50. ErrorMessage="Value must be greater than 50"
  51. EnableClientScript="true"
  52. runat="server"/>
  53. </td>
  54. </tr>
  55. <tr>
  56. <td></td>
  57. <td>
  58. <asp:Button text="Validate"
  59. OnClick="ValidateBtn_Click"
  60. runat=server />
  61. </td>
  62. <td></td>
  63. </tr>
  64. </table>
  65. </form>
  66. </body>
  67. </html>