jQuery and ASP.NET

March 21, 2009

Accept dd/mm/yyyy date format in ASP.NET AJAX MaskedEditExtender




A simple way to use the dd/mm/yyyy date format in the ASP.NET AJAX MaskedEditExtender is to use a culturename in the extender that supports this format. Shown below is an example which accepts the date in dd/mm/yyyy format and also use a MaskedEditValidator for a date field. The CultureName used here is of Great Britain "en-GB"


<asp:ScriptManager ID="ScriptManager1" runat="server">


</asp:ScriptManager>


<asp:TextBox ID="txtDate" runat="server" ValidationGroup="DtVal"/>      


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


    CultureName="en-GB" TargetControlID="txtDate"


    Mask="99/99/9999" MaskType="Date" AcceptNegative="None"/> 


<cc1:MaskedEditValidator id="MaskedEditValidator1" runat="server"


    ControlExtender="MaskedEditExtender1"


    EmptyValueMessage="Please enter Date" InvalidValueMessage="Invalid Date"


    ControlToValidate="txtDate" ValidationGroup="DtVal" />  




'Like' us on our FaceBook page if you find this blog useful. Thanks!


Did you like this post?
kick it on DotNetKicks.com Save on Delicious
subscribe via rss subscribe via e-mail
print this post follow me on twitter


About The Author

Suprotim Agarwal, ASP.NET Architecture MVP works as an Architect Consultant and provides consultancy on how to design and develop Web applications.

Suprotim is also the founder and primary contributor to DevCurry, DotNetCurry and SQLServerCurry. He has also written an EBook 51 Recipes using jQuery with ASP.NET Controls.

Follow him on twitter @suprotimagarwal

comments

2 Responses to "Accept dd/mm/yyyy date format in ASP.NET AJAX MaskedEditExtender"
  1. arpith said...
    December 29, 2009 1:26 AM

    How to do the same with a calendar extender and masked edit extender.whenever i select the date from calendar ,it comes in MM/dd/yyyy format.But i want it in dd/MM/yyyy format.Please help.

  2. Anonymous said...
    December 26, 2011 11:57 PM

    I tried this but it not works for 01/01/0000 like date

 

Copyright © 2009-2011 All Rights Reserved for DevCurry.com by Suprotim Agarwal | Terms and Conditions