开发者

how can i get Response of OK button message box in client page

开发者 https://www.devze.com 2023-04-05 07:08 出处:网络
I wrote this line of code in my project.. ClientScript.RegisterStartupScript(this.Ge开发者_C百科tType(), \"My alert\", \"alert(\'\" + mystringvariable + \"\');\", true);

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消