Click here to Skip to main content
15,881,882 members
Articles / Programming Languages / Visual Basic

Standard CustomValidator Textbox

Rate me:
Please Sign up or sign in to vote.
4.77/5 (8 votes)
4 Jun 2008CPOL3 min read 40.8K   369   20  
The Custom Control eliminates the use of adding validators for each and every textbox added. Just by setting a couple of properties we can make our textbox validate credit card numbers, phone numbers or any other Custom expression. It provides some other built in functionalities.
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="TestApp._Default" %>
 <%@ Register Assembly="CustomCtrl" Namespace="CustomCtrl.CustomCtrl" TagPrefix="uc" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">

    
    
        <table width="100%">
            <tr>
                <td>
                    Credit Card
                    <uc:CustTextBox runat="server" ID="txtCustom" IsRequired="true" ValidateItem="CreditCard"></uc:CustTextBox>
                </td>
                <td>
            </tr>
            <tr>
                <td>
                    Email
                    <uc:CustTextBox runat="server" ID="txtCustom1" IsRequired="false" ValidateItem="Email"></uc:CustTextBox>
                </td>
            </tr>
            <tr>
                <td>
                    URL
                    <uc:CustTextBox runat="server" ID="txtCustom2" IsRequired="false"  ValidateItem="URL"></uc:CustTextBox>
                </td>
            </tr>
            <tr>
                <td>
                    MonthDayYear
                    <uc:CustTextBox runat="server" ID="CustTextBox1" IsRequired="false" ValidateItem="MonthDayYear"></uc:CustTextBox>
                </td>
            </tr>
            <tr>
                <td>
                    MonthYear
                    <uc:CustTextBox runat="server" ID="CustTextBox2" IsRequired="false" ValidateItem="MonthYear"></uc:CustTextBox>
                </td>
            </tr>
            <tr>
                <td>
                    PhoneNumber
                    <uc:CustTextBox runat="server" ID="CustTextBox3" IsRequired="true" ValidateItem="PhoneNumber"></uc:CustTextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Time
                    <uc:CustTextBox runat="server" ID="CustTextBox4" IsRequired="false" ValidateItem="Time"></uc:CustTextBox>
            </tr>
        </table>
        
        
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Tata Consultancy Services
India India
I have been into Web development for past 2+ years.I've worked on areas like ASP.NET,VB.Net,Web services and web application framework DotNetNuke.I'm Microsoft Certified Professional in ASP.Net.

Comments and Discussions