Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Resources

Posted on 2007-11-30
3
Medium Priority
?
1,216 Views
Last Modified: 2008-02-01
I cant for the life of me find any site that can explain how to go about answering below. I know that the "lbtTitle.Text = " section is correct but the rest I am lost. A point in the right direction would be of great help.


You are adding a Resource file "MyResources.resx" to the global resources folder. You are also adding a new name "Title" to the file and have set the value to "Kenexa". How do you assign the value of "Title" to a Label (lbtTitle) in the code behind of a web form?


A. lbtTitle.Text = MyResources.Title
B. lbtTitle.Text = Resources.MyResources.Title
C. lbtTitle.Text = MyResources.Get("Title")
D. lbtTitle.Text = Resources.MyResources.Get("Title")

0
Comment
Question by:cybernation989
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Accepted Solution

by:
Munawar Hussain earned 1000 total points
ID: 20382040
You need to use ResourceManager to read Resource File . here is example
//TAKE INSTANCE FOR rm
 private static ResourceManager _resourceManager;
//INITIALIZE rm
public static void InitializeResources()
      {
        Assembly resourceAssembly = Assembly.GetExecutingAssembly();
        _resourceManager = new ResourceManager(
             "ResourcesDemo.TextRes", resourceAssembly);
        _resourceManager.IgnoreCase = true;
             //This is my preference. You can change this...
      }

//READ STRING WITH rm
public static string GetString(string key)
    {
      try
      {
        string s = _resourceManager.GetString( key );
        if( null == s ) throw(new Exception());
        return s;
      }
      catch
      {
        return String.Format("[?:{0}]", key);
      }
    }

YOU may fine working example here
http://www.codeproject.com/aspnet/SatResourcesDemo.asp

thanks
0
 
LVL 37

Assisted Solution

by:samtran0331
samtran0331 earned 1000 total points
ID: 20382929
With ASP.Net 2.0, you don't have to do all that to read a resource file.

cybernation989,
You didn't add your usual starting comment of "This isn't an exam or homework".
And as you did make the comment that you tried to research this, what I don't understand is
1. Why you couldn't find it by googling something like "asp.net 2.0 global resources"
2. If you just set up a test project, you could have figured it out yourself quicker that researching it.

It took me all of 3 minutes to set up the exact scenario you ask about and test it.
The answer is in the list you provided, and even if you tested by process of elimination, you would find the answer in a max of 15 minutes...

0
 

Author Comment

by:cybernation989
ID: 20401547
Oh I did find the answer I just couldnt deleted the post due to needo_jee posting
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question