views:

626

answers:

2

I am trying to set web part the title and description through a resource file. My .webpart file has this content:

<?xml version="1.0"?>
<webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3"&gt;
    <metaData>
      <type name="MyWebParts.MyWebPart" />
      <importErrorMessage>Cannot import this web part.</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="Title" type="string">$Resources:MyWebPartResources,WebPartTitle</property>
        <property name="Description" type="string">$Resources:MyWebPartResources,WebPartDescr</property>
      </properties>
    </data>
  </webPart>
</webParts>

I have put the resource file in 12\Resources folder.

But, the Add Web Part dialogue does not seem to be picking the title and description from the resource file.

Have anyone fixed this?

Update-1: On Add Web Part dialogue, I see the following instead of the text in resource file:

$Resources:MyWebPartResources,WebPartTitle
$Resources:MyWebPartResources,WebPartDescr
A: 

The resource file needs to be in websiteroot/App_GlobalResources I think.

The contents of 12/Resources folder only gets copied to App_GlobalResources when the web application is first created.

Lee Dale
putting resx file in websiteroot/App_GlobalResources is also not working.Thanks!
Vijay
A: 

The link, SharePoint Internals: Resources (given by, anchorpoint in the comment) helped a lot. Lee Dale is also correct. Though, Still it didn't work on my machine for the first time even though I was correct. It may be because of some caching issue.

Later, I tried clearing temporary internet files, deactivating and activating the feature, it worked!

Vijay
I'm glad it worked out for you. I should've put it as an answer instead of a comment ;)
anchorpoint
Yeah! Thanks!But, the entries which I had put were also correct. But, the problem was with caching. Then, clearing the temporary internet files, deactivating and activating the feature did the work for me :)
Vijay