jjrr007
asked on
Page Redirect After Clicking OK on Message Box
I am using he following code C# with a web form:
The issue I have is the page just redirects. It doesn't first display the message box and then after I click OK, then redirect.
if (result == 0)
{
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Error! Add New Item First!');", true);
Response.Redirect("~/new.aspx");
}
The issue I have is the page just redirects. It doesn't first display the message box and then after I click OK, then redirect.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. I tried this and thesame page refreshed- no message or page change. Below is what I used:
What do you suggest?
if (result == 0)
{
string message = "Error! Add New Item First. Item Does Not Exist! Being Redirected";
string url = "http://www.google.com";
string script = "window.onload = function(){ alert('";
script += message;
script += url;
script += "'; }";
ClientScript.RegisterStartupScript(this.GetType(), "Redirect", script, true);
}
What do you suggest?
I take it you did not see my post?
Hi,
Check this demo and website link, it is working fine.
http://aspsnippets.com/Articles/ASPNet-Show-JavaScript-Alert-Message-Box-and-Redirect-to-another-page-or-website.aspx
http://aspsnippets.com/demos/422/
Check this demo and website link, it is working fine.
http://aspsnippets.com/Articles/ASPNet-Show-JavaScript-Alert-Message-Box-and-Redirect-to-another-page-or-website.aspx
http://aspsnippets.com/demos/422/
ASKER
Yes, I missed your comment Kaufmed. It worked. You are the best
ASKER
Thank you for a correct, quick answer
Open in new window