Posts tagged: Ajax maskededitextender

Sep 01 2009

Ajax Masked Edit Extender,Ajax MaskedEditValidator with Ajax Calender Control

The MaskedEdit control is an ASP.NET AJAX control that can be attached to a TextBox control. The supported data formats are: Number, Date, Time, and DateTime. MaskedEdit uses the culture settings specified in the CultureName property. If none is specified the culture setting will be the same as the page: English (United States).

The MaskedEdit control has to be integrated with the MaskedEditValidator to verify the input.

It validates date formats entering. It is also used for time and number formats also.

Using Masked Edit Extender with calendar control

Step1: Open Visual Studio ,Create a new web Application (Ajax Enabled Application)

Step2: Check Script Manager is added or not in Default.aspx page. If it is not added

Drag script manager control from Ajax toolkit in Toolbox.

Step3: Add Textbox control , Ajax Calender Control, Ajax Maked Edit Extender control

step4: Set the Mask property to of the extender to  ”99/99/9999″, MaskType property “Date”, TargetControlID to “TextBox1″

step5: MaskType property plays major role for Masked Edit Extender . It describes

Mask type date, number, time and Datetime

set properties to MaskedEditExtender

ID= TextBox1_MaskedEditExtender

Mask=”99/99/9999″

MaskType=”Date”

TargetControlID=”TextBox1″


Step6: Then drag and drop MaskedEditValidator into the page. Set the properties of

the MaskedEditValidator as follows:

set properties

ControlExtender=”TextBox1_MaskedEditExtender”

ControlToValidate=”TextBox1″

Display=”Dynamic”

EmptyValueMessage=”A Date is Required”

Note: MaskedEditValidator property ControlExtender must equal to MaskedEditExtender ID i.e

MaskedEditExtender ID= TextBox1_MaskedEditExtender

MaskedEditValidator controlExtender = TextBox1_MaskedEditExtender


Sample Code look like this:

<asp:TextBox ID=”TextBox1″ runat=”server” ></asp:TextBox>

//Ajax  MaskedEditExtender

<cc1:MaskedEditExtender ID=”TextBox1_MaskedEditExtender” runat=”server”

CultureName=”en-AU”   Enabled=”True” Mask=”99/99/9999″ MaskType=”Date” TargetControlID=”TextBox1″/>

//Ajax MaskedEditValidator

<cc1:MaskedEditValidator ID=”mev1″ runat=”server”

ControlExtender=”TextBox1_MaskedEditExtender”   ControlToValidate=”TextBox1″

Display=”Dynamic”

EmptyValueMessage=”A Date is Required”

InvalidValueMessage=”The Date is Invalid”

IsValidEmpty=”False” TooltipMessage=”Please Enter a Date”/>

//Ajax CalenderExtender

<cc1:CalendarExtender ID=”CalendarExtender1″ runat=”server” PopupButtonID=”TextBox1″ Format=”dd/MM/yyyy”

TargetControlID=”TextBox1″></cc1:CalendarExtender>

Happy coding…

Alibi3col theme by Themocracy