problem with Response.redirect

Asked

Viewed 404 times

1

Response.redirect is causing my msg javascript to be undone, as I do to run redirect 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 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%>
  • Redirect does... redirect. Can’t redirect on the client side after showing the successful merge? or show the message on cadastro_cliente.asp?

  • This is the same page of this code... you’re telling me to create a new page, just with the message, and redirect to it ? but then as I go back to the page that register ?

  • If it is the same page do not understand the reason of redirect?

  • is why I have a dialog window with a form inside, only when the client performs the operation to edit the window does not disappear, then I gave a redirect to it disappear, soon after the edit action, understood ?

  • Okay, but in that case you can make one setTimeout to close window after x seconds. That’s what you want? You can show the code that opens the window?

  • i want the window to close right after the form is submitted, how do I add more code to the question ?

  • You can press the [Edit] button next to javascript andasp. The here -> [Edit]

  • Friend think you need to understand the difference of client-side and server-side.

  • @user8465 I think you should read this answer and use the ajax solution: http://answall.com/questions/6626/howto create a site-sem-reload a-cada-clique-num-link/6634#6634 So you don’t need to reload the page and you can go back to the modal/dialog via ajax. You know what I mean?

Show 4 more comments

1 answer

1

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

You can let javascript handle this:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.