Pooja Pooja - 1 month ago 12x
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?


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';",