problem with response.redirect

1

The response.redirect is causing my javascript msg to be undone, how do I run redirecit and make the message appear?

if request("action2") = "alteracliente" then
    sql3 = "update clientes set nome_cliente ='"&request("nome2")&"',descricao_cliente='"&request("descricao2")&"' where id_cliente="&request("id3")
    set objInsert = conn.Execute(sql3)
    Response.Redirect "cadastro_cliente.asp"
    Response.Write "<script>alert('Cliente alterado')</script>"
end if

Code that opens the dialog window

<%if request("id3") > 0 then%>
<script>
    $(document).ready(function(){
        $( "#dialog-confirm" ).dialog();
    });
</script>
<%end if%>

<%if request("id3") > 0 then
    sql4 = "Select * from atendentes where id_atendente="&request("id3")
    set objetodelistagem2 = conn.Execute(sql4)%>

    <div id="dialog-confirm" title="Editar atendente">
        <form action="" method="post" style="margin:20px 0px 20px 20px;" style="display:none;">
            Nome: <input type="text" name="nome2" value="<%=objetodelistagem2("nome_atendente")%>" />
            Àrea de atuação: <input type="text" name="descricao2" value="<%=objetodelistagem2("descricao_atendente")%>" /><br/>
            <input name="action2" type="hidden" value="alteracliente" />
            <input type="submit" value="Editar" class="btn btn-danger" style="margin:20px 20px 0px 45px"/>

        </form>
    </div>
<%end if%>
    
asked by anonymous 21.05.2015 / 15:00

1 answer

1

response.redirect is occurring first, simply because it comes first in the code - basically ASP ignores everything that comes after the redirect.

You can let javascript handle this:

Response.Write("<script language='javascript'>alert('Cliente alterado'); window.location.href='./cadastro_cliente.asp';</script>")
    
21.05.2015 / 21:28