I am using CultureModule.cs in my project to set culture info based on the value of my variable. Here is the example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Globalization;
namespace CwizBankApp
{
public class CultureModule:IHttpModule
{
public void Dispose()
{
}
public void Init(HttpApplication context)
{
context.PostAuthenticateRequest +=
new EventHandler(context_PostAuthenticateRequest);
}
void context_PostAuthenticateRequest(object sender, EventArgs e)
{
CultureInfo currentCulture;
if (Global.gDateFormat.Trim() == "British")
{
currentCulture = new System.Globalization.CultureInfo("en-GB");
}
else
{
currentCulture = new System.Globalization.CultureInfo("en-US");
}
System.Threading.Thread.CurrentThread.CurrentCulture
= currentCulture;
}
}
}
After this I am configuring it in web.config as follows:
<add name="CultureModule"
type="CwizBankApp.HttpModules.CultureModule,CwizBankApp"/>
Currently my variable is in British format, however dates are being performed in US format.
My question is, am I doing it in a right manner or something is still missing.
The formats depend on Thread.CurrentUICulture.
So you would do:
See how to set the Culture in asp.net on msdn.