Oħloq fajl Riżorsi jużaw Visual Studio IDE
Kopja tal-fajl tar-riżorsi fis 12 folder riżors doqqajs
GetLocalized metodu minn SPUtility biex taqra l-valuri minn fajl riżorsa
Sintassi:
SPUtility.GetLocalizedString(“$Riżorsi:<<ResourceFileName,ResourceKeyName>>”, “<<ResourceFileName>>”, twil);
Eżempju:
SPUtility.GetLocalizedString(“$Riżorsi:MyResources,FirstName”, “MyResources”, twil);
Sors Kampjun:
bl-użu Sistema;
bl-użu System.Runtime.InteropServices;
bl-użu System.Web.UI;
bl-użu System.Web.UI.WebControls;
bl-użu System.Web.UI.WebControls.WebParts;
bl-użu System.Xml.Serialization;
bl-użu Microsoft.SharePoint;
bl-użu Microsoft.SharePoint.WebControls;
bl-użu Microsoft.SharePoint.WebPartPages;
bl-użu Microsoft.SharePoint.Utilities;
namespace ResourceFile
{
[Gwida(“fc643df7-8836-41bf-913f-662ed57e659a”)]
pubbliku
klassi
ResourceCollection : System.Web.UI.WebControls.WebParts.WebPart
{
sekwenza FirstName;
sekwenza LastName;
pubbliku ResourceCollection()
{
}
protetti
override
null CreateChildControls()
{
bażi.CreateChildControls();
uint lang = SPContext.Current.Web.Language;
FirstName = SPUtility.GetLocalizedString(“$Riżorsi:MyResources,FirstName”, “MyResources”, twil);
LastName = SPUtility.GetLocalizedString(“$Riżorsi:MyResources,LastName”, “MyResources”, twil);
}
protetti
override
null Tirrendi(HtmlTextWriter kittieb)
{
writer.Write(“Valur ta 'Prim Isem minn Resource File : “ + FirstName);
writer.Write(“Valur ta Last Isem minn Resource File : “ + LastName);
}
}
}
Veri artikolu sbieħ. Fil-blog tiegħi għandi artikolu simili dwar kif tuża SPUtility.GetLocalizedString – http://dotnetfollower.com/wordpress/2011/05/the-usage-of-sputility-getlocalizedstring/