Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Can we get a strongly typed resource class rather than using resource manager
Can we get a strongly typed resource class rather than using resource manager?
✍: Guest
In the previous question we had seen how resourcemanager class can be used to read the
string from the resource file. But there has been considerable improvement in VS.Net
2005 for resource support. You no more need to load using resourcemanager class. Though
Microsoft has still kept it for backward compatibility. You can now get strongly types
classes in your VS.NET intellisense as shown in the figure below.
All belong to Resources namespace. Let’s do a small sample and see how the strongly
typed classes work in VS.NET 2005 and the simplicity which they bring while implementing
globalization in projects. Below is the screen shot of the project. It’s basically a simple
login screen with user id and password text boxes. User has options to select the language.
Currently only two languages are provided English and Greek. Depending on the languages
selected the user id and password label values will be displayed.
Below is the code snippet which describes the various important sections of the code.
First thing are the resource files. We have generated two resource files one for Greece
with el and second is the general resource file which will be used when the regional code
does not match.
There are three important steps in the code
First is set the culture information for the current thread with the new culture info
object. StrCulture has the language code which is currently selected in the drop
down.
Thread.CurrentThread.CurrentCulture = new CultureInfo(strCulture);
We set the same culture to the Resource class.
Resources.Resource.Culture = Thread.CurrentThread.CurrentCulture;
Now we are all set to use the value.
lblUserId.Text = Resources.Resource.lblUserIdResource1.ToString();
lblPassword.Text = Resources.Resource.lblPasswordResource1.ToString();
2007-11-01, 6846👍, 0💬
Popular Posts:
What is the difference between strings and character arrays? A major difference is: string will have...
How To Retrieve the Count of Updated Rows? - Oracle DBA FAQ - Working with Database Objects in PL/SQ...
what are the advantages of hosting WCF Services in IIS as compared to self hosting? There are two ma...
How To Set Up Breakpoints in Debug Mode? - Oracle DBA FAQ - Introduction to Oracle SQL Developer To ...
How To Export Data to a CSV File? - Oracle DBA FAQ - Introduction to Oracle SQL Developer If you wan...