Reputation: 221
I wrote this line of code in my project..
ClientScript.RegisterStartupScript(this.GetType(), "My alert", "alert('" + mystringvariable + "');", true);
Response.Redirect("Home.aspx");
and what happened in it that it directly jump out to Home page without popping a message.. how can it pop up a message after pressing Ok button then it should redirect on Home page...
Pls Help me ASAP.
Upvotes: 0
Views: 1658
Reputation: 538
You should rather use JS confirm, and on ok button make JS redirect like:
<html>
<head>
<script type="text/javascript">
function confirmation() {
var answer = confirm("Question?")
if (answer){
//your home.aspx
window.location = "http://www.google.com/";
}
}
</script>
</head>
<body>
<form>
<input type="button" onclick="confirmation()" value="OK">
</form>
</body>
</html>
Where should go into ClientScript.RegisterStartupScript.
Upvotes: 0
Reputation: 52270
if you look at the generated HTML you will see that you say the browser to redirect before it will begin to execute the javascript. You have to do the redirect from JS too - here is a nice tutorial
Also take a look at
Upvotes: 0