Add a project from templates called “Class Library”
Optionally in property pages of this project set the output type to Class Library..
Optionally in property pages of this project set the output type to Class Library..
Steps to create and implement Satellite Assemblies -
Satellite assemblies are resource assemblies specific to language/culture. Different resource files are created for different languages/cultures and then the needed one is loaded based on the user.
1. Create a new web application
2. Drag 2 label controls, a dropdownlist and a button control. Add 2 items to the drop down, en-US and fr-FR.
3. Add a new folder called resources and add 2 resource assembly files in it., e.g.: res1.resx and res1.fr-FR.resx In res1.resx, add a key “Welcome” and value as “Hello there”. In res1.fr-FR.resx, add a key called “Welcome” and value as “Bon Journe”.
4. Generate their resource files by using the resgen command for each of these resource files and keep them in the App_GlobalResources folder.
5. On button’s click even at the following code:
6. Session["language"]=dropdownlist1.SelectedItem .Text ;
Response.Redirect ("Webform2.aspx");
Response.Redirect ("Webform2.aspx");
7. Add a label inWebform2.aspx. In page load event of Webform2.aspx.cs add the following code.
System.Resources.ResourceManager resourceManager
=ResourceManager.CreateFileBasedResourceManager("res1",Server.MapPath("Resources")+Path.DirectorySeparatorChar , null);
string getLanguage = Session["language"].ToString ();
CultureInfo cultureInfo=new CultureInfo(getLanguage);
Label1.Text=resourceManager.GetString ("Welcome",cultureInfo);
=ResourceManager.CreateFileBasedResourceManager("res1",Server.MapPath("Resources")+Path.DirectorySeparatorChar , null);
string getLanguage = Session["language"].ToString ();
CultureInfo cultureInfo=new CultureInfo(getLanguage);
Label1.Text=resourceManager.GetString ("Welcome",cultureInfo);

0 Comments:
Post a Comment