I am using following code to display message while updating in update panel
string jv = "alert('Time OutAlert');";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", jv, true);
It works fine.
But when I use Redirect after it it loads the page without displaying the message. I want user to see the message and after clicking on "ok" it should redirect.
string jv = "alert('Time OutAlert');";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", jv, true);
Response.Redirect("~/Nextpage.aspx");
message – The message to be displayed in the JavaScript Alert Message Box. url – URL of the page or website when the user will be redirected once he clicks OK button. script – The JavaScript code that will display the Alert Message Box and then redirect.
script – The JavaScript code that will display the Alert Message Box and then redirect. string message = "You will now be redirected to ASPSnippets Home Page."; Dim message As String = "You will now be redirected to ASPSnippets Home Page."
You can not do that, the way you try because the message is running on the client side, but you make the redirect on code behind before the page loading to show the message. The way to do that is to call right after the message a client side redirect as: window.location = "NextPage.asps";
2.put a iframe with 0 width and height on your current page. 3.Set the scr of the your iframe to popup.aspx on the event you are working on. 4.create a javascript function for alert message on your popup.aspx page and call it on page's onload.
Display the alert with javascript and then do the redirect with the same:
ScriptManager.RegisterStartupScript(this,this.GetType(),"redirect",
"alert('Time OutAlert'); window.location='" +
Request.ApplicationPath + "Nextpage.aspx';",true);
You can not do that, the way you try because the message is running on the client side, but you make the redirect on code behind before the page loading to show the message.
The way to do that is to call right after the message a client side redirect as:
window.location = "NextPage.asps";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With