How to handle culture in asp.net
How to handle culture in asp.net pages
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Niradhip ChakrabortyPosted Sep 2, 2009, 1:39 AM
You can use the culture setting in web.config like this.
xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
-- GLOBALIZATION
This section sets the globalization settings of the application.
Use culture="en-US" for US
Use culture="en-GB" forUK
Use culture="en-AU" for AUS
-->
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
culture="en-GB"
/>
system.web>
configuration>
Now in the pagebehind you can refer it like below
// To get Currency Symbol and Date Format according to the Culture settings
CultureInfo ci = CultureInfo.CurrentCulture;
Session["g_CurrencySymbol"] = ci.NumberFormat.CurrencySymbol.ToString();
Session["g_CountrySetting"] = ci.Name;
if (ci.DateTimeFormat.ShortDatePattern.ToString() == "M/d/yyyy") //US Format
{
Session["g_DateFormat"] = "MM/dd/yyyy";
}
else if (ci.DateTimeFormat.ShortDatePattern.ToString() == "d/MM/yyyy") //Australian Format
{
Session["g_DateFormat"] = "dd/MM/yyyy";
}
else
{
Session["g_DateFormat"] = ci.DateTimeFormat.ShortDatePattern.ToString();
}
Raghavendra ByahattiPosted Sep 2, 2009, 11:07 AM
Master BillaPosted Sep 2, 2009, 5:38 AM
To this you need work on this style
http://msdn.microsoft.com/en-us/library/bz9tc508.aspx
thank you
Kirtan PatelPosted Sep 1, 2009, 11:53 AM
you can handle Cultures By their name
see following code
dont forget to mark "Do you like answer" if answer helped you please :)
using System.Threading;
protected void Page_Load(object sender, EventArgs e)
{
string CurrentCulture = Thread.CurrentThread.CurrentCulture.EnglishName;
if (CurrentCulture == "English (United States)")
{
//do Somthing
}
}