1. create a resource project 2. create a javascript file. The JScript1.js content is: function test () {alert (Res. failUser);} note that the property of the javascript file is "embedded resource" 3. create a resource file ScriptResource. resx: add the Resource name FailUser value Wrong user name or password! Create resource file ScriptResource. zh-CN.resx Add Resource Name FailUser value error username and password! 4. Add two references: System. Web. Extensions. dll, System. Web. Extensions. Design. dll4. register the resource file class.
[assembly: System.Web.UI.WebResource("LocalScriptResource.JScript1.js","application/x-javascript")][assembly: System.Web.UI.ScriptResource("LocalScriptResource.JScript1.js","LocalScriptResource.ScriptResource","Res")]Save this code to: Assembly. cs
5. Compile the dynamic link library 6. Add scriptmanager on the asp.net Interface
Code
<Asp: ScriptManager ID = "ScriptManager1" runat = "server" EnableScriptLocalization = "true" EnablePageMethods = "true">
<Scripts>
<Asp: ScriptReference Assembly = "LocalScriptResource" Name = "LocalScriptResource. JScript1.js"/>
</Scripts>
</Asp: ScriptManager>
7. js end call function check () {// use Res directly to call alert (Res. FailUser);} 8.cs file call ResourceManager rm=new ResourceManager("LocalScriptResource.ScriptResource",Assembly.Load("LocalScriptResource"));
rm.GetString("FailUser");