O'Reilly logo

Applied ASP.NET 4 in Context by Adam Freeman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Custom Validation Function

If the built-in validation controls (shown earlier in Table 17-1) don't match your validation needs, you can create custom validation functions using the CustomValidator control. Listing 17-14 shows the CustomValidator control applied to the TextBox control that collects the number of minutes from the user.

Listing 17-14. Using the CustomValidator control

... <div> <asp:Label ID="Label3" runat="server" Text="Minutes:" CssClass="label"/> <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> <asp:CustomValidator ID="CustomValidator1" runat="server"         ControlToValidate="TextBox3"         ErrorMessage="Enter a whole number of minutes that is less than 50"         Text="*"         onservervalidate="CustomValidator1_ServerValidate" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required