Izveidot resursu failu, izmantojot Visual Studio IDE
Kopēt resursu failu 12 strops resurss mape
GetLocalized method from SPUtility to read the values from resource file
Sintakse:
SPUtility.GetLocalizedString(“$Resursi:<<ResourceFileName,ResourceKeyName>>”, “<<ResourceFileName>>”, tikai);
Piemērs:
SPUtility.GetLocalizedString(“$Resursi:MyResources,Vārds”, “MyResources”, tikai);
Paraugs Source:
izmantojot System;
izmantojot System.Runtime.InteropServices;
izmantojot System.Web.UI;
izmantojot System.Web.UI.WebControls;
izmantojot System.Web.UI.WebControls.WebParts;
izmantojot System.Xml.Serialization;
izmantojot Microsoft.SharePoint;
izmantojot Microsoft.SharePoint.WebControls;
izmantojot Microsoft.SharePoint.WebPartPages;
izmantojot Microsoft.SharePoint.Utilities;
namespace ResourceFile
{
[Guid(“fc643df7-8836-41bf-913f-662ed57e659a”)]
valsts
class
ResourceCollection : System.Web.UI.WebControls.WebParts.WebPart
{
stīgu Vārds;
stīgu Uzvārds;
valsts ResourceCollection()
{
}
protected
override
anulēt CreateChildControls()
{
base.CreateChildControls();
uint lang = SPContext.Current.Web.Language;
FirstName = SPUtility.GetLocalizedString(“$Resursi:MyResources,Vārds”, “MyResources”, tikai);
LastName = SPUtility.GetLocalizedString(“$Resursi:MyResources,Uzvārds”, “MyResources”, tikai);
}
protected
override
anulēt Render(HtmlTextWriter writer)
{
writer.Write(“Value of First Name from Resource File : “ + Vārds);
writer.Write(“Value of Last Name from Resource File : “ + Uzvārds);
}
}
}
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/