Bug 161 - Custom Culture fails with AjaxControlToolkit MaskedEditExtender
Summary: Custom Culture fails with AjaxControlToolkit MaskedEditExtender
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Marek Habersack
URL:
Depends on:
Blocks:
 
Reported: 2011-08-03 05:55 UTC by Kamil Szostek
Modified: 2011-08-03 10:05 UTC (History)
2 users (show)

Tags: mono culture AjaxControlToolkit linux
Is this bug a regression?: ---
Last known good build:


Attachments
Sample of error page using MaskedEditExtender (1.72 MB, application/x-gzip)
2011-08-03 05:55 UTC, Kamil Szostek
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Kamil Szostek 2011-08-03 05:55:21 UTC
Created attachment 57 [details]
Sample of error page using MaskedEditExtender

I tried to run sample pages for AjaxControlToolkit. Everything works fine except some controls that rely on culture parameter, like MaskedEditExtender. It works only if culture is set to en-US (and probably auto, but from 'en' system/browser).
When I change it to my culture, which is pl-PL, it fails with:

System.IndexOutOfRangeException
Array index is out of range.

Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): AjaxControlToolkit.
Exception stack trace:
  at AjaxControlToolkit.MaskedEditExtender.set_CultureName (System.String value) [0x00000] in <filename unknown>:0 
  at AjaxControlToolkit.MaskedEditExtender.OnPreRender (System.EventArgs e) [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.PreRenderRecursiveInternal () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.PreRenderRecursiveInternal () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Control.PreRenderRecursiveInternal () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.ProcessLoadComplete () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.InternalProcessRequest () [0x00000] in <filename unknown>:0 
  at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0 


Attachment shows simple example with MaskedEditExtender and CalendarExtender that I use. web.config file is direct copy from AjaxControlToolkit sample page with globalization adjustments.

To make it work just change web.config line:
<globalization culture="pl-PL" uiCulture="pl" />
into 
<globalization culture="en-US" uiCulture="en" />

Software versions:
Linux ubuntu 2.6.32-33-generic #71-Ubuntu SMP Wed Jul 20 17:30:40 UTC 2011 i686 GNU/Linux

Mono built from GIT:
Mono JIT compiler version 2.11 (master/ff00657 pon, 1 sie 2011, 18:11:19 CEST)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  x86
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            Included Boehm (with typed GC and Parallel Mark)

xsp built from GIT:
xsp2.exe 2.11.0.0
Copyright (C) 2002-2011 Novell, Inc.
Minimalistic web server for testing System.Web

Tested in Chrome. Firefox caches stuff that makes it difficult to debug.
Comment 1 Marek Habersack 2011-08-03 10:05:13 UTC
This is two bugs in one. First is the Mono globalization data issue - we didn't have the correct short date separator specified for cultures that don't use the default '/' one. This is fixed in commits ec2cfa6e0c56a05dac9ce1add5fb4c4dd46e9225 (master) and ec0e9d777133a8094c05c5b3a9c435a540d4068d (mono-2-10 branch)

The second bug is in AjaxControlToolkit which doesn't check size of arrays resulting from a split of the short date string on the date separator specified by the corresponding CultureInfo. From ACT's MaskedEditExtender.CultureName setter:

string[] arrDate = ControlCulture.DateTimeFormat.ShortDatePattern.Split(new string[] { ControlCulture.DateTimeFormat.DateSeparator }, StringSplitOptions.None);
string ret = arrDate[0].Substring(0, 1).ToUpper(ControlCulture);
ret += arrDate[1].Substring(0, 1).ToUpper(ControlCulture);
ret += arrDate[2].Substring(0, 1).ToUpper(ControlCulture);