Sut i Ddefnyddio Ffeil Adnoddau yn SharePoint 2007

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);

}

}

}

1 comment to How to Use Resource File in SharePoint 2007

Ad a Ateb

Gallwch ddefnyddio tagiau HTML hyn

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>