I have a form with a button, when I put the button (this button actually use it for several things changing the name and using flags in the method that defines the click) this executes the JavaScript in the client but never reaches the code -behind neither in the Page_Load nor in the Click event, however the JavaScript does run.
My button:
<asp:Button runat="server" ID="btnCierre" Text="Iniciar Cierre" Style="width: 150px" Enabled="false" OnClick="btnCierre_Click" OnClientClick="return StartCierre();" UseSubmitBehavior="true" />
My JS:
<script type="text/javascript">
function StartCierre() {
if (document.getElementById("<%= btnCierre.ClientID %>").value == "Aceptar") {
document.getElementById("<%= AnimacionDeCarga.ClientID %>").style.visibility = 'visible';
document.getElementById("<%= btnDownSistema.ClientID %>").disabled = true;
document.getElementById("<%= btnCierre.ClientID %>").disabled = true;
document.getElementById("<%= btnCancel.ClientID %>").disabled = true;
}
return true;
}
</script>
All the JS is executed even the return of the true but in the code-behind I can put breakpoints in all the code and it never reaches any.
When I use the button for other things if it works.