I wrote this line of code in my project..
ClientScript.RegisterStartupScript(this.Ge开发者_C百科tType(), "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.
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
Alert and Events
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.
精彩评论