C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

Accessing Resource File (.resx) using ResourceManagerClass


Posted Date: 08 Apr 2005    Resource Type: Articles    Category: .NET Framework
Author: Sanjeev Kumar MishraMember Level: Bronze    
Rating: 1 out of 5Points: 10



Introduction



This snippet of code will explaing how to keep message in resource file (.resx) and then using it to show some message.


Example with code(VB.Net):



'***********************************************

' The next line is used when resource is in the same layer
' For Example: Resource.resx

'***********************************************
Dim rms As New System.Resources.ResourceManager("ResourceManager.Resource", Me.GetType.Assembly)

'Dim rms As New System.Resources.ResourceManager("common.IdMessage", System.Reflection.Assembly.Load("common"))


TextBox2.Text = rms.GetString(TextBox1.Text)

Explanation how to use above mentioned code:


The above code contains some codes as comment and others non-commented. If resource file ( say Resource.resx) is in the same layer then use non-commented codes otherwise if resource (say IdMessage.resx) is in any other layer then use commented codes.
First we will create an instance of ResourceManager class. That asks for two parameters, first is resource name with namespace and second is assembly.

Just take a button on the form and put the code in btnClick event.
Create two textBoxes, first for taking input (key value of the resource file) and seconde textbox will be used for showing the value when button is clicked.

Hope this explanation will be helpful.




Summary



Resource file is very handy if we want to show error messages if any exception occurs. Just put the Msg_string and the corresponding message.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Exporting Dataset in CSV, XML,XLS in ASP.Net
Previous Resource: MCMS Manager
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use