global.aspx
Design::
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center">
<table>
<tr>
<td colspan="2" align="center">
<h3 style="color: Red">
Welcome To Globalization & Localization.</h3>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server"
Text="<%$ Resources:Global.aspx, Select Language %>"></asp:Label>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
Height="25px" Width="155px"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="en-US">English</asp:ListItem>
<asp:ListItem Value="es-Mx">Spanish</asp:ListItem>
<asp:ListItem Value="de-DE">Germany</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server"
Text="<%$ Resources:global.aspx, Currency %>"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server"
Text="<%$ Resources:global.aspx, Language Name %>"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server"
Text="<%$ Resources:global.aspx, Long Date %>"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server"
Text="<%$ Resources:global.aspx, Amount %>"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="Button1" runat="server"
Text="<%$ Resources:global.aspx, Button %>" onclick="Button1_Click1"
Width="70px" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Code::
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["culture"] == "es-Mx")
{
DropDownList1.SelectedIndex = 1;
}
else if (Session["culture"] == "en-US")
{
DropDownList1.SelectedIndex = 0;
}
else if (Session["culture"] == "de-DE")
{
DropDownList1.SelectedIndex = 2;
}
}
}
protected override void InitializeCulture()
{
base.InitializeCulture();
if (Session["culture"] != null)
{
string cult = Session["culture"].ToString();
if (cult != null)
{
Culture = cult;
UICulture = cult;
}
}
else
{
string cult = Request["DropDownList1"];
if (cult != null)
{
Culture = cult;
UICulture = cult;
}
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Session["culture"] = DropDownList1.SelectedValue;
Response.Redirect("global.aspx");
}
protected void Button1_Click1(object sender, EventArgs e)
{
Session["culture"] = DropDownList1.SelectedValue;
Response.Redirect("local.aspx");
}
===================================================================
global.aspx.resx
Name value
global.aspx.de-DE.resx
global.aspx.es-Mx.resx
Name Value
Design::
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center">
<table>
<tr>
<td colspan="2" align="center">
<h3 style="color: Red">
Welcome To Globalization & Localization.</h3>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server"
Text="<%$ Resources:Global.aspx, Select Language %>"></asp:Label>
<td>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
Height="25px" Width="155px"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="en-US">English</asp:ListItem>
<asp:ListItem Value="es-Mx">Spanish</asp:ListItem>
<asp:ListItem Value="de-DE">Germany</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label2" runat="server"
Text="<%$ Resources:global.aspx, Currency %>"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server"
Text="<%$ Resources:global.aspx, Language Name %>"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server"
Text="<%$ Resources:global.aspx, Long Date %>"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server"
Text="<%$ Resources:global.aspx, Amount %>"></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="Button1" runat="server"
Text="<%$ Resources:global.aspx, Button %>" onclick="Button1_Click1"
Width="70px" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Code::
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["culture"] == "es-Mx")
{
DropDownList1.SelectedIndex = 1;
}
else if (Session["culture"] == "en-US")
{
DropDownList1.SelectedIndex = 0;
}
else if (Session["culture"] == "de-DE")
{
DropDownList1.SelectedIndex = 2;
}
}
}
protected override void InitializeCulture()
{
base.InitializeCulture();
if (Session["culture"] != null)
{
string cult = Session["culture"].ToString();
if (cult != null)
{
Culture = cult;
UICulture = cult;
}
}
else
{
string cult = Request["DropDownList1"];
if (cult != null)
{
Culture = cult;
UICulture = cult;
}
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Session["culture"] = DropDownList1.SelectedValue;
Response.Redirect("global.aspx");
}
protected void Button1_Click1(object sender, EventArgs e)
{
Session["culture"] = DropDownList1.SelectedValue;
Response.Redirect("local.aspx");
}
===================================================================
global.aspx.resx
Name value
| Amount | Amount |
| Currency | Currency |
| Language Name | Language Name |
| Long Date | Long Date |
| welcome | welcome |
| Select Language | Select Language |
| Button | Button |
global.aspx.de-DE.resx
| Name Select Language | Value Wählen Sie Sprache |
| Long Date | Long Date |
| Language Name | Sprache Name |
| Currency | Währung |
| Button | Taste |
| Amount | Höhe |
Name Value
| Amount | cantidad |
| Currency | moneda |
| Language Name | idioma Nombre |
| Long Date | Fecha de largo |
| welcome | bienvenida |
| Select Language | Selecciona Idioma de la |
| Button | botón |
No comments:
Post a Comment