How to use Masked Edit ajax validator control for Date ?


Mask

If we have to validate Textbox for Date format then “Ajax Masked Edit” control is one of the easiest solution to do this task. We can do like this

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Image ID="Image1" ImageUrl="~/Calendar_scheduleHS.png" runat="server" />
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>

        <asp:MaskedEditExtender   
            ID="MaskedEditExtender1"  
            runat="server"  
            TargetControlID="TextBox1" 
            Mask="99/99/9999"   
            MaskType="Date" 
           CultureName="en-US" 
            MessageValidatorTip="true"/>  
     
         
        <asp:MaskedEditValidator   
            ID="MaskedEditValidator1"  
            runat="server"  
            ControlToValidate="TextBox1"  
            ControlExtender="MaskedEditExtender1"  
            IsValidEmpty="false"/>  
    
        <asp:CalendarExtender ID="CalendarExtender1" TargetControlID="TextBox1" format="dd/MM/yyyy"  PopupButtonID="Image1" runat="server"/>
        <br />
    </div>
    </form>
</body>
</html>


Advertisements
Posted in Ajax. 1 Comment »

One Response to “How to use Masked Edit ajax validator control for Date ?”

  1. SutoCom Says:

    Reblogged this on Sutoprise Avenue, A SutoCom Source.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: