How to replace the date AjaxToolkit CalendarExtender with the conversion of string?

advertisements

i am using the Microsoft Ajax Toolkit CalendarExtender control, to add calendar drop-down functionality to a regular TextBox:

<asp:TextBox ID="edStartDate" runat="server" />
<asp:CalendarExtender ID="CalendarExtender1" runat="server"
      TargetControlID="edStartDate" />

Which works fine for most client locales. It seems that the control does a server-request in order to convert a DateTime into a localized String.

For example, today (October 1st, 2012) displays fine in Arabic 15/11/33:

And also displays fine in Lower Sorbian 1. 10. 2012:


But some locales do not display properly in .NET 1////10////2012:

In this case i need some sort of OnFormatDate event, that i can supply the correct localization of a date to a string. Which leads to my question:

How to override AjaxToolkit CalendarExtender date to string conversion?


Note: Don't confuse the question with the example.

  • i'm asking how to customize the conversion of a date to a string in a CalendarExtender
  • even if i'm not dealing with a bug in .NET, it doesn't change my question
  • even if i'm not dealing with a CalendarExtender, i'm still asking the question

In your page... at the top of it... you have something like:

<%@ Page Language="C#" AutoEventWireup="true" %>

Adding there something like(spanish for example)...

<%@ Page Language="C#" AutoEventWireup="true" UICulture="es" Culture="es-MX" %>

and in your scriptmanager

EnableScriptLocalization="true" EnableScriptGlobalization="true"

will pretty much overwrite the local settings...

But i guess you only want this property to set in your CalendarExtender:

Format="yyyy-MM-dd" or Format="dd/MM/yyyy" or however you like...