<%@ 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>
Your name:
<asp:TextBox ID="name" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="name"
ErrorMessage="You must provide your name."></asp:RequiredFieldValidator><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
|