Click here to Skip to main content
13,052,669 members (63,097 online)
Click here to Skip to main content
Add your own
alternative version


10 bookmarked
Posted 24 Mar 2009

DateTimeFormat DD/MM/YYYY in Ajax tool kit 4.0

Rate this:
Please Sign up or sign in to vote.
The big problem using date time format in dd/mm/yyyy using ajax tool kit 4.0


We use Date Time Format in a dd/mm/yyyy using Ajax Tool Kit 4.0


Some problem using DateTimeFormat in a dd/mm/yyyy with using AjaxToolKit 4.0. mostly programmer avoid to using calender extender due to some reason.

Using the Code

Firstly you add up CultureInfo class through System.Diagnostic name space,then use the TRYPARSExact method for correct date time Don,t Forget to add up a property name of "CULTURE NAME" in MaskEditExtender (Below which is mark in a REd colour).

stStartDate  = txtStartDate1.Text;
stEndDate    =  txtEndDate1.Text;
CultureInfo enBR = new CultureInfo("pt-BR");

// check date Time Format 

DateTime startDate = new DateTime();

DateTime endDate = new DateTime();

if(txtStartDate1.Text == "__/__/____" && txtEndDate1.Text =="__/__/____")
{ }           
 if(txtStartDate1.Text != "__/__/____" || txtEndDate1.Text !="__/__/____")

    if (txtStartDate1.Text != "__/__/____" && txtEndDate1.Text !="__/__/____")

               if (DateTime.TryParseExact(stStartDate,"dd/MM/yyyy",
                  enBR,DateTimeStyles.None,out startDate)
                  && DateTime.TryParseExact(stEndDate,"dd/MM/yyyy",
                  enBR,DateTimeStyles.None,out endDate) )
                     // something 


<cc1:MaskedEditValidator ID="MaskedEditValidator3" runat="server"

 ControlExtender="MaskedEditExtenderSD2" ControlToValidate="txtStartDate1"

  CssClass="RedLabel" Display="Dynamic" EmptyValueBlurredText="*"

 ErrorMessage="MaskedEditValidator10" InvalidValueBlurredMessage="Invalid Date"

  InvalidValueMessage="Valid Start of Date required" IsValidEmpty="False" 

 ValidationExpression="^\d{2}/\d{2}/\d{4}$" ValidationGroup="Form">(dd/mm/yyyy)

<cc1:CalendarExtender ID="CalendarExtenderSD2" runat="server" Enabled="True" 

 Format="dd/MM/yyyy" PopupButtonID="ImageButtonCalendar1"


 <cc1:MaskedEditExtender ID="MaskedEditExtenderSD2" runat="server"

     ClearMaskOnLostFocus="False" Enabled="True" Mask="99/99/9999" MaskType="Date" 

 TargetControlID="txtStartDate1" CultureAMPMPlaceholder="" 

 CultureCurrencySymbolPlaceholder="" CultureDateFormat="" 

 CultureDatePlaceholder="" CultureDecimalPlaceholder="" 

 CultureThousandsPlaceholder="" CultureTimePlaceholder="" CultureName="pt-BR"> 


Points of Interest

It is so simple to use ajaxtoolkit for a datetime format.

Not too much lengthy code to write for date time format


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


About the Authors

Jason Troitsky
United Kingdom United Kingdom
No Biography provided

No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
Ray Hayes24-Mar-09 8:52
memberRay Hayes24-Mar-09 8:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 24 Mar 2009
Article Copyright 2009 by Jason Troitsky, zuhair haroon khan software programmer
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid