Follow us

Tuesday, January 18, 2011

Reading a Global Resource File (.resx)


The .resx resource file format consists of XML entries, which specify objects and strings inside XML tags.
  • A .resx file contains a standard set of header information, which describes the format of the resource entries and specifies the versioning information for the XML used to parse the data.
  • Following the header information, each entry is described as a name/value pair. When a string is added to a .resx file, the name of the string is embedded in a <data>  tag, and the value is enclosed in a <value>  tag, as in the following example.

        Enter your mailing address
        E-mail id of user
        Enter your Name
        Name of user
        Thanks for providing information.

  • An advantage of a .resx file is that when opened with a text editor (such as Notepad or Microsoft Word) it can be written to, parsed, and manipulated.

How to read string from .resx resource file?

Reading a string in .cs file

//Name of resource file is 'Technoscatter.resx'
//'ReadText'is the name of string
string text = Resources.Technoscatter.ReadText;

We can also set 'text' property of .NET controls in design mode as:

<asp:label id="Label1" runat="server" text="<%$Resources:Technoscatter,Name %>"></asp:label>
<asp:label id="Label2" runat="server" text="<%$Resources:Technoscatter,Email %>"></asp:label>


Sr.No Download Size
1 Reading a string from .resx resource file 6KB

Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

3 comments: on "Reading a Global Resource File (.resx)"

Raj [ Microsoft Certified Technology Specialist (MCTS) ] said...

nice one buddy... keep going... all the best


Harry said...

Hi, Can I use resx file data for rquired filed validator and what is xml:space .. please guide me


Aashish Khandelwal said...

@Harry ...could u plz elaborate what actually u r trying to do?

Post a Comment