using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Resources; //import following Namespace first using System.Globalization; //import following Namespace first using System.Threading; //import following Namespace first using System.Reflection; //import following Namespace first namespace Multilanguagesupport { public partial class WebForm1 : System.Web.UI.Page { ResourceManager rm; CultureInfo ci; protected void Page_Load(object sender, EventArgs e) { if (Session["Lang"] == null) { Session["Lang"] = Request.UserLanguages[0]; } if (!IsPostBack) { LoadString(); //This function is used to translate languages based on selected languages } } private void LoadString() { Thread.CurrentThread.CurrentCulture = new CultureInfo(Session["Lang"].ToString()); rm = new ResourceManager("Multilanguagesupport.App_GlobalResources.Lang", Assembly.GetExecutingAssembly()); //we configure resource manages for mapping with resource files in App_GlobalResources folder. ci = Thread.CurrentThread.CurrentCulture; studname.Text = rm.GetString("StudentName", ci); //Name is the resource manager string name that should mathch with Name solumn of resorce files and if that matches then the value against the name will be translated as mentioned for each languages. Label2.Text = rm.GetString("DateOfBirth", ci); //same as// Label4.Text = rm.GetString("Gender", ci); //same as// Label3.Text = rm.GetString("Address", ci);//same as// Submit.Text = rm.GetString("Submit", ci);//same as// btnBack.Text = rm.GetString("Back", ci);//same as// reqfield.Text = rm.GetString("StudentReqfield", ci); Label5.Text = rm.GetString("MobileNumber", ci);//same as// Label1.Text = rm.GetString("District", ci);//same as// Label6.Text = rm.GetString("Taluk", ci);//same as// Label7.Text = rm.GetString("EmailID", ci);//same as// } protected void ddLang_SelectedIndexChanged(object sender, EventArgs e) //this event for showing selected language. { Session["Lang"] = ddLang.SelectedValue; LoadString(); } } }