Thursday, June 9, 2011

Understanding the RESX Resource Files

(from article Peter Morath)

"When you first start looking through a SharePoint 2010 aspx page you realize that there isn’t an awful lot of actual changeable code in them. Its is pretty much impossible to decode the cryptic references used by the ASP.NET controls, such as text boxes, labels."

For example: <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,login_pageUserName%>" EncodeMethod='HtmlEncode'/>

You’ve found the wss.resx file under "drive:\inetput\wwwroot\wss\VirtualDirectories\app_name\App_GlobalResources".
Open the wss.resx file in text or application editor such Visual Studio 2010 or Notepad++ and find variable "login_pageUserName"

For example:
<data name="login_pageUserName">
<value>User name:</value>
</data>

To change the value of login_pageUserName (text), please rename this variable in aspx-file. For example, login_pageUserName_new
<SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,login_pageUserName_new%>" EncodeMethod='HtmlEncode'/>

And add new data element in wss.resx file such as
<data name="login_pageUserName_new">
<value>Customer name:</value>
</data>

If you were to change the contents between the <value>…</value> tags, the changes would be picked up by all aspx pages that referenced it.

No comments:

Post a Comment