Set a control's meta:resourcekey property programatically

Posted on 2009-12-24
Last Modified: 2012-05-08
Is there a way to set the meta:resourcekey property of a control programatically?  Here's why I'm asking.  I'm developing a multi-language app.  I have a label on my form that will display error message text.  I'd like the message to be informative so I want to create resourcekeys for each anticipated error and then assign the appropriate resourcekey when the error occurs.  Is this possible?  Thanks!

P.S.  By the way, I'm developing in VB so if you have any code examples in VB, that would be appreciated.
Question by:penlandt
    LVL 10

    Accepted Solution

    Assume that you have YourResourceFile.resx in your App_GlobalResources folder. You can read a resouce using

    Label1.Text = Resources.YourResourceFile.ResourceName.ToString();
    LVL 12

    Expert Comment

    LVL 1

    Author Closing Comment

    I can't believe the solution was so simple.  I searched all over and couldn't find anything online about this.  All the examples I could find showed how to access resources through your HTML but nothing about doing it this way.  Thanks for the quick and useful help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now