RequiredFieldValidator Demo: You must enter your name (VB.net)
<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<script runat=server>
</SCRIPT>
<HTML>
<HEAD>
<TITLE>RequiredFieldValidator Control Sample Page</TITLE>
</HEAD>
<BODY >
<form runat="server">
<Font Face="Tahoma">
<BR><BR>
<asp:Label
id="lblMessage"
runat="server"
Font-Bold="True"
Text="Name"
/>
<asp:TextBox
id="txtName"
Columns="25"
MaxLength="30"
runat=server
Text="Name"
/>
<asp:RequiredFieldValidator
id="rfvName"
ControlToValidate="txtName"
InitialValue="Name"
Display="Dynamic"
Font-Name="Verdana"
Font-Size="10pt"
runat=server
>
You must enter your name!
</asp:RequiredFieldValidator>
<BR><BR>
<asp:Label
id="lblMessage2"
runat="server"
Font-Bold="True"
Text="Name 2"
/>
<asp:TextBox
id="txtName2"
Columns="25"
MaxLength="30"
runat=server
Text="Name"
/>
<asp:RequiredFieldValidator
id="rfvName2"
ControlToValidate="txtName2"
InitialValue="Name"
Display="Dynamic"
Font-Name="Verdana"
Font-Size="10pt"
runat=server
>
You must replace name with your name!
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator
id="rfvName3"
ControlToValidate="txtName2"
Display="Dynamic"
Font-Name="Verdana"
Font-Size="10pt"
runat=server
>
You must enter a name!
</asp:RequiredFieldValidator>
<BR><BR>
<asp:button
id="butOK"
text="OK"
Type="Submit"
runat="server"
/>
</Font>
</Form>
</BODY>
</HTML>
Related examples in the same category