Create Resource file using Visual Studio IDE
Copy the resource file into 12 hive resource folder
GetLocalized method from SPUtility to read the values from resource file
वाक्य-विन्यास:
SPUtility.GetLocalizedString(“$Resources:<<ResourceFileName,ResourceKeyName>>”, “<<ResourceFileName>>”, lang);
उदाहरण:
SPUtility.GetLocalizedString(“$Resources:MyResources,FirstName”, “MyResources”, lang);
Sample Source:
का उपयोग करते हुए System;
का उपयोग करते हुए System.Runtime.InteropServices;
का उपयोग करते हुए System.Web.UI;
का उपयोग करते हुए System.Web.UI.WebControls;
का उपयोग करते हुए System.Web.UI.WebControls.WebParts;
का उपयोग करते हुए System.Xml.Serialization;
का उपयोग करते हुए Microsoft.SharePoint;
का उपयोग करते हुए Microsoft.SharePoint.WebControls;
का उपयोग करते हुए Microsoft.SharePoint.WebPartPages;
का उपयोग करते हुए Microsoft.SharePoint.Utilities;
namespace ResourceFile
{
[Guid(“fc643df7-8836-41bf-913f-662ed57e659a”)]
सार्वजनिक
class
ResourceCollection : System.Web.UI.WebControls.WebParts.WebPart
{
तार FirstName;
तार LastName;
सार्वजनिक ResourceCollection()
{
}
protected
override
शून्य CreateChildControls()
{
base.CreateChildControls();
uint lang = SPContext.Current.Web.Language;
FirstName = SPUtility.GetLocalizedString(“$Resources:MyResources,FirstName”, “MyResources”, lang);
LastName = SPUtility.GetLocalizedString(“$Resources:MyResources,LastName”, “MyResources”, lang);
}
protected
override
शून्य Render(HtmlTextWriter writer)
{
writer.Write(“Value of First Name from Resource File : “ + FirstName);
writer.Write(“Value of Last Name from Resource File : “ + LastName);
}
}
}
Veri nice article. In my blog I have similar article on how to use SPUtility.GetLocalizedString – http://dotnetfollower.com/wordpress/2011/05/the-usage-of-sputility-getlocalizedstring/