Tsim Resource ntaub ntawv siv siv qhov muag saib Studio IDE
Luam tau cov chaw muab kev qhia ntawv rau hauv 12 nas muv nplaub tshev qho
GetLocalized txoj kev ntawm SPUtility mus nyeem rau qhov tseem ceeb ntawm cov chaw muab kev qhia ntaub ntawv
Syntax:
SPUtility.GetLocalizedString(“$Kev pab:<<ResourceFileName,ResourceKeyName>>”, “<<ResourceFileName>>”, lang);
Piv txwv:
SPUtility.GetLocalizedString(“$Kev pab:MyResources,FirstName”, “MyResources”, lang);
Coj mus kuaj tau qhov twg los:
siv Tsim;
siv System.Runtime.InteropServices;
siv System.Web.UI;
siv System.Web.UI.WebControls;
siv System.Web.UI.WebControls.WebParts;
siv System.Xml.Serialization;
siv Microsoft.SharePoint;
siv Microsoft.SharePoint.WebControls;
siv Microsoft.SharePoint.WebPartPages;
siv Microsoft.SharePoint.Utilities;
namespace ResourceFile
{
[Guid(“fc643df7-8836-41bf-913f-662ed57e659a”)]
pej xeem
hoob
ResourceCollection : System.Web.UI.WebControls.WebParts.WebPart
{
hlua FirstName;
hlua LastName;
pej xeem ResourceCollection()
{
}
kev tiv thaiv
override
khoob lug CreateChildControls()
{
puag.CreateChildControls();
uint lang = SPContext.Current.Web.Language;
FirstName = SPUtility.GetLocalizedString(“$Kev pab:MyResources,FirstName”, “MyResources”, lang);
LastName = SPUtility.GetLocalizedString(“$Kev pab:MyResources,LastName”, “MyResources”, lang);
}
kev tiv thaiv
override
khoob lug Kav(HtmlTextWriter kws ntawv)
{
txawj sau ntawv.Sau ntawv(“Tus nqi ntawm lub npe ntawm tus thov kev pab : “ + FirstName);
txawj sau ntawv.Sau ntawv(“Tus nqi ntawm lub xeem los ntawm cov chaw muab kev qhia ntawv : “ + LastName);
}
}
}
Veri tsab xov xwm zoo. Nyob rau hauv kuv cov blog kuv muaj zoo xws li tsab xov xwm siv SPUtility.GetLocalizedString yuav ua li cas – http://dotnetfollower.com/wordpress/2011/05/the-usage-of-sputility-getlocalizedstring/