How to Use Resource File in SharePoint 2007

Create Resource file using Visual Studio IDE

Copy the resource file into 12 hive resource folder

GetLocalized method from SPUtility to read the values from resource file

वाक्य-विन्यास:

SPUtility.GetLocalizedString(“$Resources:<<ResourceFileName,ResourceKeyName>>”, “<<ResourceFileName>>”, lang);

उदाहरण:

SPUtility.GetLocalizedString(“$Resources:MyResources,FirstName”, “MyResources”, lang);

Sample Source:

का उपयोग करते हुए System;

का उपयोग करते हुए System.Runtime.InteropServices;

का उपयोग करते हुए System.Web.UI;

का उपयोग करते हुए System.Web.UI.WebControls;

का उपयोग करते हुए System.Web.UI.WebControls.WebParts;

का उपयोग करते हुए System.Xml.Serialization;

का उपयोग करते हुए Microsoft.SharePoint;

का उपयोग करते हुए Microsoft.SharePoint.WebControls;

का उपयोग करते हुए Microsoft.SharePoint.WebPartPages;

का उपयोग करते हुए Microsoft.SharePoint.Utilities;

namespace ResourceFile

{

[Guid(“fc643df7-8836-41bf-913f-662ed57e659a”)]


सार्वजनिक
class
ResourceCollection : System.Web.UI.WebControls.WebParts.WebPart

{


तार FirstName;


तार LastName;


सार्वजनिक ResourceCollection()

{

}


protected
override
शून्य CreateChildControls()

{


base.CreateChildControls();


uint lang = SPContext.Current.Web.Language;

FirstName = SPUtility.GetLocalizedString(“$Resources:MyResources,FirstName”, “MyResources”, lang);

LastName = SPUtility.GetLocalizedString(“$Resources:MyResources,LastName”, “MyResources”, lang);

}


protected
override
शून्य 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

एक उत्तर दें छोड़ दो

आप का उपयोग कर सकते हैं इन HTML टैग

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