1
I am developing a project that by clicking the button next to the ASP.NET Webforms application runs a dynamic code (this script is built on each page loading, Dynamic.JS - it is translated from C#programming blocks) and then in the same event you should call the relative functions in Validacoes.JS. The only problem is the execution order. The application calls Validacoes.JS before Dynamic.JS and for the application to behave as expected it needs Dynamic.JS to run first. How do I do that?
OBS: Calling one function within another would not be a viable solution for me. The name of the Function associated with the next button varies from page to page in the Dynamic.JS file
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Validacoes.JS ---> No momento é o primeiro a ser executado... deveria ser executado após o Dynamic.JS
// no ProximoButton esse evento verificacaoProximo está no onclick!
function verificacaoProximo() {
if (retorno == "avanca") {
if ($("#HiddenFielPodeAvancarTela").val().toString() == "0") { // PodeAvancar NAO
if ($("#HiddenFielPodeAvancarTelaFlag").val().toString() == "1")
retorno = "avanca";
else
retorno = "naoavanca";
}
else { // PodeAvancar SIM
if ($("#HiddenFielPodeAvancarTelaFlag").val().toString() == "1")
retorno = "avanca";
else
retorno = "naoavanca";
}
}
return retorno;
}
//Dynamic.JS
$(document).ready(function () {
// HiddenField
if (!document.getElementById("hfcerto") ) {
var input792 = document.createElement("input");
input792.setAttribute("type","hidden");
input792.setAttribute("name", "hfcerto");
input792.setAttribute("value", "0");
input792.setAttribute("id", "hfcerto");
document.getElementById("hfs").appendChild(input792);
}
// HiddenField
if (!document.getElementById("hferro") ) {
var input121 = document.createElement("input");
input121.setAttribute("type","hidden");
input121.setAttribute("name", "hferro");
input121.setAttribute("value", "0");
input121.setAttribute("id", "hferro");
document.getElementById("hfs").appendChild(input121);
}
$("#ProximoButton892").click(function(){
prox_click();
});
});
function prox_click(){
if((document.getElementById("hfcerto").getAttribute("value")=="8")&&(document.getElementById("hferro").getAttribute("value")=="0")){
document.getElementById("ImageButton1").src = document.getElementById("ImageButton2").src;
}
else if((document.getElementById("hfcerto").getAttribute("value")=="5")&&(document.getElementById("hferro").getAttribute("value")=="0")){
document.getElementById("ImageButton1").src = document.getElementById("ImageButton2").src;
}
else {
document.getElementById("ImageButton1").src = document.getElementById("PictureBoxProp891").src;
var valorHF = document.getElementById("HiddenFielQtdExercErrados").getAttribute("value");
document.getElementById("HiddenFielQtdExercErrados").setAttribute("value", parseInt(document.getElementById("HiddenFielQtdExercErrados").getAttribute("value")) + 1);
}
return false;
}
Could you publish your code? It would be easier to help like this. (;
– Felipe Avelar
Would it help? Remembering that it is dynamic! Each screen features different codes...
– LeandroSJRP
Published code @Felipeavelar
– LeandroSJRP