Strongly typed resource class, DOT NET Programming

Can we get a strongly typed resource class?

You can now get strongly types classes in the VS.NET intellisense as shown in the figure below.

42_resource class.png

Figure: - Strongly typed resource class

All belongs to the Resources namespace. Let do a small sample and see how the strongly typed classes work in the VS.NET 2005 and the simplicity which they bring while implementing globalization in the projects. The screen shot of the project is shown below. It is basically a simple login screen with user id and password text boxes. The User has options to select the language. Currently only two languages are provided English & Greek. Depending on the selected languages the user id and password label values will be displayed.

1013_resource class1.png

Figure: - Strongly typed project

The code snippet below describes the various important parts of the code. The First thing is the resource files. We have generated two resource files one for Greece with el and the second is the general resource file which will be used when the regional code does not match.

2357_resource class2.png

Figure: - Walkthrough for using the resources namespace

There are three main steps in the code:-

1) The First step is to set the culture information for the current thread with the new culture info object. The StrCulture has the language code which is presently selected in the drop down.

Thread.CurrentThread.CurrentCulture = new CultureInfo(strCulture);

2) We set the similar culture to the Resource class.

Resources.Resource.Culture = Thread.CurrentThread.CurrentCulture;

 3) Now we are all set to use the value.

lblUserId.Text = Resources.Resource.lblUserIdResource1.ToString();

lblPassword.Text = Resources.Resource.lblPasswordResource1.ToString();

Posted Date: 9/25/2012 3:55:28 AM | Location : United States







Related Discussions:- Strongly typed resource class, Assignment Help, Ask Question on Strongly typed resource class, Get Answer, Expert's Help, Strongly typed resource class Discussions

Write discussion on Strongly typed resource class
Your posts are moderated
Related Questions
What is BCP utility in SQL SERVER? The Bulk Copy Program (BCP) is a command line utility by which you can import & export large amounts of data in and out of the SQL SERVER dat

Project Description: We have a reconciliation tool, written in VB.Net that selects customer data (email, addresses, etc) from three different data sources and compares them with

Question: (a) List the two main advantages of developing a Multitiered Web Applications. (b) Explain how Validation controls are used to validate forms. (c) Using com

How can you use Hidden frames to cache client data? This technique is implemented by developing a Hidden frame in page which will have your data to be cached. T cols="100

What are the various ways of authentication techniques in ASP.NET? The Selection of  an authentication provider is as simple as making an entry in  the web.config file of  the

In which statement the LINQ query is executed? A LINQ query is executed in the For every statement in Visual Basic and in the for each statement in C#.

What are the difference b/w System.String and System.StringBuilder classes? The System.StringBuilder can have mutable string where a variety of operations can be performed whil

What is the use of the CommandBuilder class? The CommandBuilder class is used to automatically update a database according to the changes made in a DataSet. This class autom

Project Description:  You require access to a commercial version of the 3CX PBX system in order to be able to program the API You need sufficient technical knowledge about PB

I want to prepare one web based application which have student registration and according to semester and every time it will change as per semester change according, now student ge