SmartDate Default Format

SmartDate Default Format

Old forum URL: forums.lhotka.net/forums/t/2365.aspx


JoeFallon1 posted on Friday, February 16, 2007

In my web app in Global.asax I just add this code to the Application Start event handler:

SmartDate.SetDefaultFormatString("MM/dd/yyyy")

This changed the default output of all SmartDates to use leading zeros on dates.

This adds a lot of consistency to my screens and reports. I standardized the output on dozens of reports with this one line of code.

Rocky  - just wanted to say thanks for adding it to the framework.

It was a little thing but it just came in very handy.

Joe

RockfordLhotka replied on Friday, February 16, 2007

My pleasure! Smile [:)]

jkellywilkerson replied on Friday, February 16, 2007

Hey Joe or Rocky,

Can the same be done in the App.config or some other startup file for Windows CSLA Apps?

Kelly.

RockfordLhotka replied on Friday, February 16, 2007

You could certainly do so, yes. CSLA doesn’t do it for you, but it is just Joe’s line of code, but with the format string retrieved using System.Configuration.ConfigurationManager – not hard.

 

Rocky

 

From: jkellywilkerson [mailto:cslanet@lhotka.net]
Sent: Friday, February 16, 2007 11:55 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] SmartDate Default Format

 

Hey Joe or Rocky,

Can the same be done in the App.config or some other startup file for Windows CSLA Apps?

Kelly.



jkellywilkerson replied on Friday, February 16, 2007

Would I put something like SmartDate.SetDefaultFormatString("MM/dd/yyyy") in program.cs; I have been using

return _birthdate.Date.ToString("MM/dd/yyyy");

in each SmartDate Property Get method.  But, if I could set it globally at runtime similar to the way Joe did using Global.asax, that would be much nicer.

Thanks,

Kelly.

Copyright (c) Marimer LLC