[ASP.NET 3.5] Appeller une variable serveur depuis un fichier js
:salut:
J'utilise dans mon code différents javascript pour du CustomValidtor.
Si j'intègre ce code sur ma page ascx, ca tourne sans problème :
Code:
1 2 3 4 5 6 7 8 9 10
|
function CustomValidatorTransLOC(source, arguments) {
if (document.getElementById('<%= chkTransmisSSC.ClientID %>').checked
&& getCheckedRadio(<%= RadioButtonListSaleStatus.ClientID %>.id) != 21) {
if (ValidatorTrim(arguments.Value).length > 0 && ValidatorTrim(arguments.Value) != -1){
arguments.IsValid = true;
}else{
arguments.IsValid = false;
}} else { arguments.IsValid = true; }
} |
De même si je l'inclue depuis le code behind :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "CustomValidatorTransLOC",
"function CustomValidatorTransLOC(source, arguments) {"
+ "if (document.getElementById('" + chkTransmisSSC.ClientID + "').checked "
+ "&& getCheckedRadio(" + RadioButtonListSaleStatus.ClientID + ".id) != 21) {"
+ "if (ValidatorTrim(arguments.Value).length > 0 && ValidatorTrim(arguments.Value) > -1){"
+ "arguments.IsValid = true;"
+ "}else{"
+ "arguments.IsValid = false;"
+ "}} else { arguments.IsValid = true; }"
+ "}",
true); |
Seulement, j'aimerais mettre tous ces codes dans un fichier .js, afin de bien séparer les différents types de codes, mais les balises de code behind (<%= %>) ne sont pas interprété dans ce cas.
Comment faire ?
Merci :ccool: