Búa Resource skrá með Visual Studio IDE
Afritaðu vefsíðuna skrá inn 12 Hive auðlind mappa
GetLocalized method from SPUtility to read the values from resource file
Setningafræði:
SPUtility.GetLocalizedString(“$Resources:<<ResourceFileName,ResourceKeyName>>”, “<<ResourceFileName>>”, aðeins);
Dæmi:
SPUtility.GetLocalizedString(“$Resources:MyResources,FirstName”, “MyResources”, aðeins);
Dæmi Source:
með System;
með System.Runtime.InteropServices;
með System.Web.UI;
með System.Web.UI.WebControls;
með System.Web.UI.WebControls.WebParts;
með System.Xml.Serialization;
með Microsoft.SharePoint;
með Microsoft.SharePoint.WebControls;
með Microsoft.SharePoint.WebPartPages;
með Microsoft.SharePoint.Utilities;
namespace ResourceFile
{
[GUID(“fc643df7-8836-41bf-913f-662ed57e659a”)]
almennings
class
ResourceCollection : System.Web.UI.WebControls.WebParts.Web
{
band FirstName;
band LastName;
almennings ResourceCollection()
{
}
protected
override
ógilt CreateChildControls()
{
base.CreateChildControls();
uint lang = SPContext.Current.Web.Language;
FirstName = SPUtility.GetLocalizedString(“$Resources:MyResources,FirstName”, “MyResources”, aðeins);
LastName = SPUtility.GetLocalizedString(“$Resources:MyResources,LastName”, “MyResources”, aðeins);
}
protected
override
ógilt 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/