Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Monday, November 28, 2011

Programmatically get resource files in sharepoint 2010

Programmatically get resource files in sharepoint 2010

In this post we will learn how to access resource files saved in sharePoint 2010′s 14 hive in our webpart. I have a resource file below as an example


Click me


Click me tooltip

You can use this button in your CreatechildControls of your webpart as below

protected override void CreateChildControls()
{
Button b = new Button();
ResourceManager rm = new ResourceManager(“WebParts.ResourceWebPart.NonVisualWebPart”, this.GetType().Assembly);
b.Text = rm.GetString(“Button.Text”);
b.OnClientClick = “ShowAlert(this)”;
Controls.Add(b);
base.CreateChildControls();
}

No comments:

Post a Comment