Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

257
Visualizações
How to prevent multiple execution of a javascript event with .net framework

I am making an application with .net framework which performs multiple autopostbacks, but I am performing the data validations with javascript, so that the javascript continues to "work" after performing an autopostback, I use Sys.Application.add_load, in my javascript, but Doing that creates a problem for me, and that is that every time there is an autopostback, the event returns and is executed, that is, if I perform 3 autopostbacks, the click event is executed 3 times.

<asp:Button ID="btn_guardar" runat="server" CssClass="boton" Text="Guardar" OnClick="btn_guardar_Click" />

<script defer>
    Sys.Application.add_load(() => {
        ...

        btn_guardar.addEventListener('click', e => {
            if (txt_Val_A_Conciliar.value === '') {
                alert('No se ha declarado un valor a conciliar');
                e.preventDefault();
                return;
            
            if (txt_Val_A_Conciliar.value !== valorNuevo.toString()) {
                valorNuevo = 0;
                alert('Los valores conciliados no son iguales al valor a conciliar');
                e.preventDefault();
                return;
            
            panelProcesoAdministrativos.forEach(panelProcesoAdministrativo => {
                if (panelProcesoAdministrativo.value === '') {
                    alert('Existen campos vacios');
                    e.preventDefault();
                    return;
                }
            })
        })
    })
</script>
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda