Mencipta fail Sumber menggunakan IDE Visual Studio
Salin fail sumber ke dalam 12 folder sumber sarang
GetLocalized method from SPUtility to read the values from resource file
Sintaksis:
SPUtility.GetLocalizedString(“$Sumber:<<ResourceFileName,ResourceKeyName>>”, “<<ResourceFileName>>”, hanya);
Contoh:
SPUtility.GetLocalizedString(“$Sumber:MyResources,FirstName”, “MyResources”, hanya);
Contoh Sumber:
menggunakan System;
menggunakan System.Runtime.InteropServices;
menggunakan System.Web.UI;
menggunakan System.Web.UI.WebControls;
menggunakan System.Web.UI.WebControls.WebParts;
menggunakan System.Xml.Serialization;
menggunakan Microsoft.SharePoint;
menggunakan Microsoft.SharePoint.WebControls;
menggunakan Microsoft.SharePoint.WebPartPages;
menggunakan Microsoft.SharePoint.Utilities;
namespace ResourceFile
{
[GUID(“fc643df7-8836-41bf-913f-662ed57e659a”)]
awam
class
ResourceCollection : System.Web.UI.WebControls.WebParts.WebPart
{
rentetan FirstName;
rentetan LastName;
awam ResourceCollection()
{
}
protected
override
tidak sah CreateChildControls()
{
base.CreateChildControls();
uint lang = SPContext.Current.Web.Language;
FirstName = SPUtility.GetLocalizedString(“$Sumber:MyResources,FirstName”, “MyResources”, hanya);
LastName = SPUtility.GetLocalizedString(“$Sumber:MyResources,LastName”, “MyResources”, hanya);
}
protected
override
tidak sah 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/