Creu ffeil adnoddau gan ddefnyddio Visual Studio IDE
Copïwch Ffeil adnoddau i mewn 12 ffolder adnoddau cwch gwenyn
GetLocalized method from SPUtility to read the values from resource file
Cystrawen:
SPUtility.GetLocalizedString(“$Adnoddau:<<ResourceFileName,ResourceKeyName>>”, “<<ResourceFileName>>”, yn unig);
Enghraifft:
SPUtility.GetLocalizedString(“$Adnoddau:MyResources,Firstname”, “MyResources”, yn unig);
Sampl Ffynhonnell:
gan ddefnyddio System;
gan ddefnyddio System.Runtime.InteropServices;
gan ddefnyddio System.Web.UI;
gan ddefnyddio System.Web.UI.WebControls;
gan ddefnyddio System.Web.UI.WebControls.WebParts;
gan ddefnyddio System.Xml.Serialization;
gan ddefnyddio Microsoft.SharePoint;
gan ddefnyddio Microsoft.SharePoint.WebControls;
gan ddefnyddio Microsoft.SharePoint.WebPartPages;
gan ddefnyddio Microsoft.SharePoint.Utilities;
namespace ResourceFile
{
[GUID(“fc643df7-8836-41bf-913f-662ed57e659a”)]
cyhoeddus
class
ResourceCollection : System.Web.UI.WebControls.WebParts.WebPart
{
llinyn Firstname;
llinyn Lastname;
cyhoeddus ResourceCollection()
{
}
protected
override
gwag CreateChildControls()
{
base.CreateChildControls();
uint lang = SPContext.Current.Web.Language;
FirstName = SPUtility.GetLocalizedString(“$Adnoddau:MyResources,Firstname”, “MyResources”, yn unig);
LastName = SPUtility.GetLocalizedString(“$Adnoddau:MyResources,Lastname”, “MyResources”, yn unig);
}
protected
override
gwag 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/