Pooja Pooja - 1 year ago 97
Javascript Question

How to get alert message before redirect a page

I'm using vs 2010. I need to display the message to user and redirect the page.

I use the below line.

ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "<script> alert('User details saved sucessfully');window.open('frmDisplayUsers.aspx');</script>", true);

But I didn't get the alert message and the page was directly redirected.

How to get alert message?

Answer Source

Your code is opening window but you asking for a redirect, below is an example of a redirect:

ScriptManager.RegisterStartupScript(this, this.GetType(), 
"alert('User details saved sucessfully');window.location ='frmDisplayUsers.aspx';", 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download