The Program below is a demo for using local and global resource files to implement globalization : dont be confused with the drop down list items :)use the following link to study more about globalization http://www.ezzylearning.com/tutorial.aspx?tid=3477182
WorkingwithEmail.aspx
<%@ Page Language="C#" AutoEventWireup="true" Theme="themeDark" EnableViewState ="true" ViewStateMode ="Enabled" CodeFile="WorkingwithEmail .aspx.cs"
Inherits="WorkingwithEmail_" culture="auto" meta:resourcekey="PageResource1" uiculture="auto" %>
<!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></title>
<style type="text/css">
#showiftrue
{
width: 109px;
}
#showiffalse
{
width: 112px;
}
</style>
</head>
<body bgcolor="Black">
<form id="form1" runat="server">
<center>
<fieldset class="fieldsetStyle">
<legend class="legendStyle">SignUp</legend>
<br />
<asp:DropDownList ID="ddlCulture" runat="server" AutoPostBack="True"
meta:resourcekey="ddlCultureResource1">
<asp:ListItem Value="ur-PK" Text ="Burushaski" meta:resourcekey="ListItemResource1"></asp:ListItem>
<asp:ListItem Value ="en" Text ="English" meta:resourcekey="ListItemResource2"></asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:Localize ID="Localize1" runat="server" Mode="PassThrough"
meta:resourcekey="Localize1Resource1" Text="Saadiya Dad"></asp:Localize>
<br />
<br />
<br />
<asp:Label ID="lblEntermail" runat ="server"
meta:resourcekey="lblEntermailResource1"></asp:Label>
<asp:TextBox runat="server" AutoPostBack="True" ID="txtEmailID"
OnTextChanged="txtEmailID_TextChanged" meta:resourcekey="txtEmailIDResource1"></asp:TextBox>
<table>
<tr>
<td>
<div runat="server" id="showiftrue" visible="false">
<asp:Image ID="Image2" runat="server" ImageUrl="avail.jpg" Width="106px"
meta:resourcekey="Image2Resource1" />
</div>
</td>
<td>
<div runat="server" id="showiffalse" visible="false">
<asp:Image ID="Image1" runat="server" ImageUrl="notavailable.jpg" Width="109px"
meta:resourcekey="Image1Resource1" /></div>
</td>
</tr>
</table>
<asp:Label ID="lblStatus" runat="server" meta:resourcekey="lblStatusResource1"
EnableViewState="False" ViewStateMode="Disabled"></asp:Label>
<br />
<br />
<br />
<br />
<table>
<tr>
<td>
<asp:Label ID="lblName" runat="server" Text="Name: "
meta:resourcekey="lblNameResource1"></asp:Label><br />
<asp:Label ID="lblFName" runat="server" Text="Father's Name: "
meta:resourcekey="lblFNameResource1"></asp:Label><br />
<asp:Label ID="lblAge" runat="server" Text="Age: "
meta:resourcekey="lblAgeResource1"></asp:Label><br />
<asp:Label ID="lblCountry" runat="server" Text="Country: "
meta:resourcekey="lblCountryResource1"></asp:Label><br />
<asp:Label ID="lblEmail" runat="server" Text="Email: "
meta:resourcekey="lblEmailResource1"></asp:Label><br />
</td>
<td>
<br />
<asp:TextBox ID="txtName" runat="server" EnableViewState="False"
ViewStateMode="Disabled" meta:resourcekey="txtNameResource1"></asp:TextBox><br />
<asp:TextBox ID="txtFName" runat="server" EnableViewState="False"
ViewStateMode="Disabled" meta:resourcekey="txtFNameResource1"></asp:TextBox><br />
<asp:TextBox ID="txtAge" runat="server" EnableViewState="False"
ViewStateMode="Disabled" meta:resourcekey="txtAgeResource1"></asp:TextBox><br />
<asp:TextBox ID="txtCountry" runat="server" EnableViewState="False"
ViewStateMode="Disabled" meta:resourcekey="txtCountryResource1"></asp:TextBox><br />
<asp:TextBox ID="txtEmail" runat="server" EnableViewState="False"
ViewStateMode="Disabled" meta:resourcekey="txtEmailResource1"></asp:TextBox><br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
onclick="btnSubmit_Click" meta:resourcekey="btnSubmitResource1" /><br />
</td>
</tr>
</table>
<br />
<br />
<asp:Label ID="lblShow" runat ="server" meta:resourcekey="lblShowResource1" ></asp:Label>
</fieldset>
</center>
</form>
</body>
</html>
Inherits="WorkingwithEmail_" culture="auto" meta:resourcekey="PageResource1" uiculture="auto" %>
<!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></title>
<style type="text/css">
#showiftrue
{
width: 109px;
}
#showiffalse
{
width: 112px;
}
</style>
</head>
<body bgcolor="Black">
<form id="form1" runat="server">
<center>
<fieldset class="fieldsetStyle">
<legend class="legendStyle">SignUp</legend>
<br />
<asp:DropDownList ID="ddlCulture" runat="server" AutoPostBack="True"
meta:resourcekey="ddlCultureResource1">
<asp:ListItem Value="ur-PK" Text ="Burushaski" meta:resourcekey="ListItemResource1"></asp:ListItem>
<asp:ListItem Value ="en" Text ="English" meta:resourcekey="ListItemResource2"></asp:ListItem>
</asp:DropDownList>
<br />
<br />
<asp:Localize ID="Localize1" runat="server" Mode="PassThrough"
meta:resourcekey="Localize1Resource1" Text="Saadiya Dad"></asp:Localize>
<br />
<br />
<br />
<asp:Label ID="lblEntermail" runat ="server"
meta:resourcekey="lblEntermailResource1"></asp:Label>
<asp:TextBox runat="server" AutoPostBack="True" ID="txtEmailID"
OnTextChanged="txtEmailID_TextChanged" meta:resourcekey="txtEmailIDResource1"></asp:TextBox>
<table>
<tr>
<td>
<div runat="server" id="showiftrue" visible="false">
<asp:Image ID="Image2" runat="server" ImageUrl="avail.jpg" Width="106px"
meta:resourcekey="Image2Resource1" />
</div>
</td>
<td>
<div runat="server" id="showiffalse" visible="false">
<asp:Image ID="Image1" runat="server" ImageUrl="notavailable.jpg" Width="109px"
meta:resourcekey="Image1Resource1" /></div>
</td>
</tr>
</table>
<asp:Label ID="lblStatus" runat="server" meta:resourcekey="lblStatusResource1"
EnableViewState="False" ViewStateMode="Disabled"></asp:Label>
<br />
<br />
<br />
<br />
<table>
<tr>
<td>
<asp:Label ID="lblName" runat="server" Text="Name: "
meta:resourcekey="lblNameResource1"></asp:Label><br />
<asp:Label ID="lblFName" runat="server" Text="Father's Name: "
meta:resourcekey="lblFNameResource1"></asp:Label><br />
<asp:Label ID="lblAge" runat="server" Text="Age: "
meta:resourcekey="lblAgeResource1"></asp:Label><br />
<asp:Label ID="lblCountry" runat="server" Text="Country: "
meta:resourcekey="lblCountryResource1"></asp:Label><br />
<asp:Label ID="lblEmail" runat="server" Text="Email: "
meta:resourcekey="lblEmailResource1"></asp:Label><br />
</td>
<td>
<br />
<asp:TextBox ID="txtName" runat="server" EnableViewState="False"
ViewStateMode="Disabled" meta:resourcekey="txtNameResource1"></asp:TextBox><br />
<asp:TextBox ID="txtFName" runat="server" EnableViewState="False"
ViewStateMode="Disabled" meta:resourcekey="txtFNameResource1"></asp:TextBox><br />
<asp:TextBox ID="txtAge" runat="server" EnableViewState="False"
ViewStateMode="Disabled" meta:resourcekey="txtAgeResource1"></asp:TextBox><br />
<asp:TextBox ID="txtCountry" runat="server" EnableViewState="False"
ViewStateMode="Disabled" meta:resourcekey="txtCountryResource1"></asp:TextBox><br />
<asp:TextBox ID="txtEmail" runat="server" EnableViewState="False"
ViewStateMode="Disabled" meta:resourcekey="txtEmailResource1"></asp:TextBox><br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
onclick="btnSubmit_Click" meta:resourcekey="btnSubmitResource1" /><br />
</td>
</tr>
</table>
<br />
<br />
<asp:Label ID="lblShow" runat ="server" meta:resourcekey="lblShowResource1" ></asp:Label>
</fieldset>
</center>
</form>
</body>
</html>
WorkingwithEmail.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Globalization;
using System.Threading;
public partial class WorkingwithEmail_ : System.Web.UI.Page
{
protected override void InitializeCulture()
{
if (Request.Form["ddlCulture"] != null)
{
UICulture = Request.Form["ddlCulture"];
}
base.InitializeCulture();
}
protected void Page_Load(object sender, EventArgs e)
{
//foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
//{
// ddlCulture.Items.Add(new ListItem(ci.NativeName, ci.Name));
//}
Thread.CurrentThread.CurrentCulture=new CultureInfo (ddlCulture.SelectedItem.Value);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(ddlCulture.SelectedItem.Value);
Page.Culture = ddlCulture.SelectedItem.Value;
Page.UICulture = ddlCulture.SelectedItem.Value;
if (IsPostBack)
{
ViewState["name"] = txtName.Text;
ViewState["FName"] = txtFName.Text;
ViewState["Age"] = txtAge.Text;
ViewState["Country"] = txtCountry.Text;
ViewState["Email"] = txtEmail.Text;
}
else
{
lblName.Font.Size = FontUnit.Large;
lblFName.Font.Size = FontUnit.Large;
lblAge.Font.Size = FontUnit.Large;
lblCountry.Font.Size = FontUnit.Large;
lblEmail.Font.Size = FontUnit.Large;
}
}
protected void txtEmailID_TextChanged(object sender, EventArgs e)
{
SqlConnection connection = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\inetpub\wwwroot\Profile\App_Data\EmailID.mdf;Integrated Security=True;User Instance=True");
DataSet ds = new DataSet();
SqlCommand cmdShow = new SqlCommand("Select Email from Mail where Email='"+txtEmailID .Text+ "'", connection);
SqlDataAdapter da = new SqlDataAdapter(cmdShow);
da.Fill(ds);
DataTable dt = null;
dt = ds.Tables[0];
if (dt.Rows.Count != 0)
{
showiffalse.Visible = true;
Image2.Visible = false;
Image1.Visible = true;
lblStatus.EnableViewState = false;
lblStatus.Text = GetGlobalResourceObject("MyGlobalResource","labelstatus").ToString();
}
else
{
showiftrue.Visible = true;
Image1.Visible = false;
Image2.Visible = true;
lblStatus.EnableViewState = false;
lblStatus.Text = GetGlobalResourceObject("MyGlobalResource", "labelntStatus").ToString();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
lblShow.ForeColor = System.Drawing.Color.BlanchedAlmond;
lblShow.Text = " Hello " + ViewState["name"] + " " + ViewState["FName"] + " from " + ViewState["Country"] + " You are " + ViewState["Age"] + " years old ";
//lblShow.Text = " Hello " + txtName.Text + " " + txtFName .Text + " from " + txtCountry .Text + " You are " + txtAge .Text + " years old ";
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Globalization;
using System.Threading;
public partial class WorkingwithEmail_ : System.Web.UI.Page
{
protected override void InitializeCulture()
{
if (Request.Form["ddlCulture"] != null)
{
UICulture = Request.Form["ddlCulture"];
}
base.InitializeCulture();
}
protected void Page_Load(object sender, EventArgs e)
{
//foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
//{
// ddlCulture.Items.Add(new ListItem(ci.NativeName, ci.Name));
//}
Thread.CurrentThread.CurrentCulture=new CultureInfo (ddlCulture.SelectedItem.Value);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(ddlCulture.SelectedItem.Value);
Page.Culture = ddlCulture.SelectedItem.Value;
Page.UICulture = ddlCulture.SelectedItem.Value;
if (IsPostBack)
{
ViewState["name"] = txtName.Text;
ViewState["FName"] = txtFName.Text;
ViewState["Age"] = txtAge.Text;
ViewState["Country"] = txtCountry.Text;
ViewState["Email"] = txtEmail.Text;
}
else
{
lblName.Font.Size = FontUnit.Large;
lblFName.Font.Size = FontUnit.Large;
lblAge.Font.Size = FontUnit.Large;
lblCountry.Font.Size = FontUnit.Large;
lblEmail.Font.Size = FontUnit.Large;
}
}
protected void txtEmailID_TextChanged(object sender, EventArgs e)
{
SqlConnection connection = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\inetpub\wwwroot\Profile\App_Data\EmailID.mdf;Integrated Security=True;User Instance=True");
DataSet ds = new DataSet();
SqlCommand cmdShow = new SqlCommand("Select Email from Mail where Email='"+txtEmailID .Text+ "'", connection);
SqlDataAdapter da = new SqlDataAdapter(cmdShow);
da.Fill(ds);
DataTable dt = null;
dt = ds.Tables[0];
if (dt.Rows.Count != 0)
{
showiffalse.Visible = true;
Image2.Visible = false;
Image1.Visible = true;
lblStatus.EnableViewState = false;
lblStatus.Text = GetGlobalResourceObject("MyGlobalResource","labelstatus").ToString();
}
else
{
showiftrue.Visible = true;
Image1.Visible = false;
Image2.Visible = true;
lblStatus.EnableViewState = false;
lblStatus.Text = GetGlobalResourceObject("MyGlobalResource", "labelntStatus").ToString();
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
lblShow.ForeColor = System.Drawing.Color.BlanchedAlmond;
lblShow.Text = " Hello " + ViewState["name"] + " " + ViewState["FName"] + " from " + ViewState["Country"] + " You are " + ViewState["Age"] + " years old ";
//lblShow.Text = " Hello " + txtName.Text + " " + txtFName .Text + " from " + txtCountry .Text + " You are " + txtAge .Text + " years old ";
}
}