show-notice
hide-notice

Saturday, 13 July 2013

How to use Globalization Culture in Asp.Net


Introduction

i will explain How to use Globalization Culture in Asp.Net.


Description

define culture-related information, including the language, the country/region,
the calendars in use, the format patterns for dates, currency, and numbers, and
the sort order for strings. These classes are useful for writing globalized (internationalized) applications. We will show you a simple sample about how to write a globalized calendar in ASP.NET.



Example





<%@
page language="C#" autoeventwireup="true" codefile="how-to-use-globalization-culture-c.aspx.cs"
    inherits="how_to_use_globalization_culture_c"
%>
<!DOCTYPE
html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head
runat="server">
    <title>How to
use Globalization Culture</title>
</head>
<body>
    <form id="form1"
runat="server">
    <div>
       
<
asp:calendar id="Calendar1" runat="server"></asp:calendar>
       
<
br />
       
<
asp:radiobuttonlist id="RadioButtonList1" runat="server" autopostback="True" width="174px"
           
onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
           
<asp:ListItem Value="en-US">English
( en-US )</asp:ListItem>
           
<asp:ListItem Value="zh-CN">Chinese
( zh-CN )</asp:ListItem>
           
<asp:ListItem Value="de-DE">Deutsch
( de-DE )</asp:ListItem>
       
</
asp:radiobuttonlist>
    </div>
    </form>
</body>
</html>
 
 

C#



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class how_to_use_globalization_culture_c
: System.Web.UI.Page

{

    protected void RadioButtonList1_SelectedIndexChanged(object
sender, EventArgs e)

    {

        System.Threading.Thread.CurrentThread.CurrentCulture
= new System.Globalization.CultureInfo(this.RadioButtonList1.SelectedValue);

        System.Threading.Thread.CurrentThread.CurrentUICulture
= new System.Globalization.CultureInfo(this.RadioButtonList1.SelectedValue);

    }

}


SHARE THIS POST   

0 comments :

Post a Comment

Design by Gohilinfotech | www.gohilinfotech.blogspot.com