locked
response.redirect with messagebox RRS feed

  • Question

  • User-1578974752 posted

    Hi

    I have few code after the message box. if certain condition didn't satisy then I want to show a message and redirect to home page.

    below code when I place ,after redirecting it is executing the code below the portion of message box which is a saving process. As the project is live I don't want to change the full code. Thanks

    ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('Maximum number of Attempt for Test is 4. times');window.location='Userhome.aspx';", True)

    when I put response .redirect under this code.message is not showing.

    Thanks

    Monday, November 18, 2019 8:37 AM

All replies

  • User753101303 posted

    Hi,

    The location header sent by using Response.Redirect is processed first and the content of the page is basically irrelevant.

    Depends on your overall approach but you could have the target page showing this message. You don't stay on the same page ? It seems a loign page and you show a message after 4 failed connexion attempts ?

    Monday, November 18, 2019 9:00 AM
  • User-719153870 posted

    Hi shsu,

    As far as i know, Response.Redirect() is at the very top of the order where your program execute the code, especially around the alert message code.

    You can refer to response.redirect executing before alert message and How to get alert message before redirect a page.

    I think you have found the solution to your problem, right? It doesn't work or you met some new problems?

    ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('Maximum number of Attempt for Test is 4. times');window.location='Userhome.aspx';", True)

    By the way, if you used the window.location then you can quit the response.redirect.

    Best Regard,

    Yang Shen

    Tuesday, November 19, 2019 2:29 AM