问题
I am using validationEngine jquery 2.6.2 for validation in ASP.NET. I want to load its language rules file according to the language selected like English or Japanese. I am using master page in the application. Give some solution for this.
回答1:
You didn't specify how the language are selected and how you are going to check the current selected language.
To localize validationEngine, you must reference the right script language.
If you use a Script Manager, in the code behind of your Master Page you can reference dinamically the localization script.
The Script Manager markup declaration:
<asp:ScriptManager ID="scrManager" runat="server">
<Scripts>
<asp:ScriptReference Path="~/js/jquery.validationEngine.js" />
</Scripts>
</asp:ScriptManager>
Then you can add dynamically your language script (code behind):
ScriptReference validationEngineLanguage = new ScriptReference();
// #### Assign the correct script reference based on the selected language #####
validationEngineLanguage.Path = "~/js/jquery.validationEngine-en.js";
this.scrManager.Scripts.Add(validationEngineLanguage);
Another option to dinamically reference the script would be get the tag reference in codebehind and add the script tag.
来源:https://stackoverflow.com/questions/14524881/validationengine-jquery-not-working-properly-for-localization