protected Type ResourceType { get { return typeof(MyResources); // replace 'MyResources' with your own resources file } }
2. Create the following method which will return the requested value stored in the .resx file by looking up the resource key
protected string GetResourceString(Type resourceType, string resourceKey) { return SPUtility.GetLocalizedString(string.Format("$Resources:{0}, {1}", resourceType.Name, resourceKey), resourceType.FullName, getLanguage); }
3. Good to go. Say you would need to populate a label in the Page_Load event with a string stored in the resources file with a key called 'MyLabelText'; you can then achieve this as follows:
protected void Page_Load(object sender, EventArgs e) { lblMyLabel.Text = GetSourceString(ResourceType, "MyLabelText"); }