Posts tagged: ajax calender control

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…

Aug 29 2009

Asp.net Ajax Calender Control

Ajax Calender control:

Ajax Calender Control is an asp.net control associated with Textbox. When the user clicks on the textbox it pops up. It provides client-side date-picking functionality with customizable date format and UI in a popup control. The user can then set a date by clicking on a day, navigate months by clicking on the left and right arrow and perform other such actions without a postback.

How to use Ajax Calender control in Asp.net

1)     In Aspx Page add one TextBox id is txtDate  and Ajax Calender control.

2)    Sample Code :

<%@ Register Assembly=”AjaxControlToolkit” Namespace=”AjaxControlToolkit” TagPrefix=”cc1” %> //add this

<asp:TextBox ID=”txtDate” runat=”server” ></asp:TextBox>

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

1)       TargetControlID – The ID of the Textbox to extend with the calendar.

(In Our Example TargetControlID is txtDate)

2)       CssClass – Name of the CSS class used to style the calendar. See the Calendar Theming section for more information.

3)     FormatFormat string used to display the selected date.

Formats:       “dd/MM/yyyy”

           "MMMM d, yyyy"

4)    PopupButtonID – The ID of a control to show the calendar popup when clicked. If this value is not set, the calendar will pop up when the textbox receives focus.

(In Our Example PopupControlID  is txtDate)

5)       PopupPosition – Indicates where the calendar popup should appear at the BottomLeft(default), BottomRight, TopLeft, TopRight, Left or Right of the TextBox.

Explaination: When user clicks in TextBox (txtDate), the ajax calendar control will popup and the selected date will be displayed in TextBox (txtDate)

Alibi3col theme by Themocracy