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.
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 ?
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.
Member
183 Points
401 Posts
response.redirect with messagebox
Nov 18, 2019 08:37 AM|shsu|LINK
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
All-Star
48510 Points
18071 Posts
Re: response.redirect with messagebox
Nov 18, 2019 09:00 AM|PatriceSc|LINK
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 ?
Contributor
3140 Points
983 Posts
Re: response.redirect with messagebox
Nov 19, 2019 02:29 AM|Yang Shen|LINK
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