CalendarExtender and getting the correct date format

When using the CalendarExtender from the Ajax Control Toolkit to add pop up functionality to a text box, there are a couple of things you need to do to ensure that the date format in the text box is correct for your culture.

Firstly, add Culture and UI Culture information to your web.config file. In short add an element to the <system.web> section. In my case (UK English) I add <globalization uiCulture="en" culture="en-GB" /> to this element.

For example:

<system.web>
    <globalization uiCulture="en" culture="en-GB" />
</system.web>

Secondly, you need to instruct the script manager to actually take note of this. You do this by setting the EnableScriptGlobalization and EnableScriptLocalization to true as properties of the ScriptManager.

For example:

<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"
    EnablePartialRendering="true"
    EnableScriptGlobalization="true"
    EnableScriptLocalization="true">
</cc1:ToolkitScriptManager>

Done deal <grin>

Advertisements

7 thoughts on “CalendarExtender and getting the correct date format

  1. lifesaver – couldn’t get the thing to correctly enter date into database – was always blowing with datetime mismatch….must have saved me hours of messing around. thanks v much!

  2. This is the kind of tips they DON’T tell you about in the MS walkthroughs and how-tos.

    Has saved me many hours of digging!

    Cheers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s