I\'m working on localizing a website in French. However I am not supposed to change the date format to French. It must remain as per en-us format even if the culture is set
To change how dates are formatted you could create a custom CultureInfo, based on an existing CultureInfo (in your case "fr-CA"), modifying only the date formats. I don't have any experience in this, but the linked aricle and this article explains how it's done. Supposedly, it's not too difficult.
I imagine that setting System.Threading.Thread.CurrentThread.CurrentCulture
to an instance of your custom CultureInfo (e.g. in the Page.Load event) should do the job.
Or, use the CultureInfo class to specify culture on a per-string basis:
CultureInfo culture = new CultureInfo("en-US");
Whenever you write a date to the page, use the following syntax:
myDate.ToString("d", culture);
or
string.Format(
culture,
"This is a string containing a date: {0:d}",
myDate);
The CultureInfo class resides in the System.Globalization
namespace and d
in the above is the format in which to output the date. See John Sheehan's ".NET Format String Quick Reference" cheat sheet for more on format strings.