Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a strange issue ... I want to retrieve resources programmatically from a SharePoint default resource file wss. So in one of my controls im executing the following code:

 protected override void CreateChildControls()
        {
            this.Controls.Clear();
            LiteralControl literalControl = new LiteralControl();//"<%$Resources:wss,view_selector_view%>");
            string view=SPUtility.GetLocalizedString("$Resources:wss,view_selector_view", "wss", SPContext.Current.Web.Language);
            literalControl.Text = view;
            this.Controls.Add(literalControl);

            base.CreateChildControls();
        }

It seems to be ok, and I found examples which use the same way BUT the result I get is not what i want to see: There result is following:

"$Resources:wss,view_selector_view;"

What do i miss?

Update: After investigating the issue, I discorvered that SPUtility doesn't find the wss.resx files, as it is located in 14hive/Resources, BUT it searches in the wwwroot/App_GlobalResrouces ... is it normal that a webcontrol cannot retrieve resources from 14/Resources?

I had to search for another key which would provide me the value, but view_selector_view was a perfect match ... but not accesible as it was in wss.

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

When the key cannot be found in the resource file, the GetLocalizedString method will simply spit back out what you sent it. Which is what you are seeing there.

I'm not positive, but I would try to remove the "wss," from the first parameter in GetLocalizedString. I don't believe it is necessary as the second parameter is specifying the file.

share|improve this answer
    
Yes, I investigated the log files and it cannot find WSS.resx but it is strange, because it searches for files in 14hive/resources and NOT in App_GlobalResources, why? It is just a webcontrol, shouldn't it retrieve resources from app_globalresources in wwwroot? –  Shkipper Aug 22 '12 at 5:51
    
Yes the .GetLocalizedString() method will look in the 14/Resources. The resource files in this folder, and this method, more correspond to localizing SharePoint elements rather than your applications. I found this link to be a fairly detailed explanation: platinumdogs.me/2010/08/09/… –  CMN Aug 23 '12 at 1:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.