Altinet
  • Home
  • Blog
  • Contact





[Format_BadDateTime] DataForm validation error, broken binding on DatePicker, all that only on Windows XP!

On 02 Aug, 2011
Uncategorized
By : Bruno Samardzic
With 1 Comment
Views : 7201

Ok, this one was a real pain in the ass. I would get this strange [Format_BadDateTime] error when trying to type in a Date in any of the DatePickers i would try to use. And only on Windows XP.
If i would use it outside the DataForm my binding would just get broken and that would basically be it!
On a different project, with similair setup i would get a [Arg_TargetInvocationException].

The problem occurs only if you’re using non-English localization settings on client computer (which means date formats other than MM/dd/yyyy) on Windows xp.
Well, i figured it out and it’s the Range attribute!
Range attribute is constituted pretyy awkard, ie for custom values it uses property type and string representations of minimum and maximum values. I think you can already see where’s the problem coming from:). Don’t know why it is different on WinXP or why it can’t figure it out there but basically what you need to do is keep it in the invariantCulture to avoid any problems:

((DateTime)someDate).ToString(CultureInfo.InvariantCulture)

where the end product would look something like this:

[Range(typeof(DateTime), @”01/01/1753 00:00:00″, @”01/01/9999 00:00:00″)]

And that’s it! Lost a good day on that crap, because my silverlight codegenerator used the local culture…

Oh, and i think that this problem is actually connected to my dev machine having different culture setup than english



Previous Post Next Post 

About The Author

Bruno Samardzic


Number of Posts : 45
All Posts by : Bruno Samardzic

Comments ( 1 )

  • marek Aug 23 , 2011 at 2:22 am / Reply

    Another way to solve this problem, is to set a CultureInfo of the current thread.

    System.Threading.Thread.CurrentThread.CurrentCulture=System.Globalization.CultureInfo.InvariantCulture;


Leave a Comment

Click here to cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>





Recent Posts

  • Angular vs React: round 2
  • Why programming is hard
  • Orchard Workflows, undocumented gem
  • The React Redux
  • React.js invoicing CRUD application, part 2: Description

Recent Comments

  • Angshuman on Animation for starred grid rows and columns using xaml
  • Advanced Excel Training in Lucknow on Angular vs React: round 2
  • Reginald Sophomore on My example of Angularjs directive
  • Slobodan on Angular and Breeze – story so far.
  • Bruno Samardzic on Reaction to Ember-forged Durandal Angularly Knocking out my Backbone, or my JS MVC framework research conclusion.

Contact

Altinet d.o.o.

OIB: 97429091194

Čulinečka cesta 146, Zagreb

Tel: +385 (1) 2946 819

Mob: +385 (98) 210 756

IBAN: HR4323400091110406470

Latest tweets