<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="MyPage" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Total number of children:
<asp:TextBox ID="totalChildren" runat="server" Columns="4"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="totalChildren"
ErrorMessage="The total number of children must be a whole number greater than or equal to 0"
Operator="GreaterThanEqual" Type="Integer" ValueToCompare="0"></asp:CompareValidator><br />
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Click Me" />
<br />
<br />
<asp:Label ID="results" runat="server"></asp:Label></div>
</form>
</body>
</html>
File: Default.aspx.vb
Partial Class MyPage
Inherits System.Web.UI.Page
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
If Page.IsValid Then
results.Text = "Input is valid..."
Else
results.Text = "Input is <b>not</b> valid..."
End If
End Sub
End Class
|