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?
For displaying alert message after redirection you may use Session or QueryString and on page Load check if the Session or QueryString is not empty then display alert message.
The JavaScript function first displays the alert message box using the JavaScript window onload event, and then redirects the user to the specified page using the window location method.
PHP doesn't support alert message box because it is a server-side language but you can use JavaScript code within the PHP body to alert the message box on the screen.
Your code is opening window but your asking for a redirect, below is an example of a redirect:
ScriptManager.RegisterStartupScript(this, this.GetType(),
"alert",
"alert('User details saved sucessfully');window.location ='frmDisplayUsers.aspx';",
true);
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