ASP .NET代码问题,小帮助 [英] ASP .NET code issue, small help

查看:71
本文介绍了ASP .NET代码问题,小帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void Page_Load(object sender, EventArgs e)
    {
        int result = 0;
         Response.Write("<script>var a=confirm('You are about to change the shipping status of Order Id:! Are you sure you want to continue?');if(a==true){ "+result++ +"}; </script>");
         Response.Write("" + result);
    }



大家好,
我在这里分享一小段代码.我的目标是,仅当"a"为真时,结果"变量值才应增加.但是,无论我单击确认框的确定"还是取消"按钮,它均不起作用.它总是在增加结果变量.请让我知道原因和任何解决方法.



Hi All,
I am sharing a small piece of code here. My objective is that the ''result'' variable value should increase only if ''a'' is true. But it is not working irrespective of whether i am clicking on ''OK'' or ''Cancel'' button of the confirm box. It is always increasing the result variable. Please let me know the reason and any workaround.

推荐答案

Response.Write("<script>var a=confirm('You are about to change the shipping status of Order Id:! Are you sure you want to continue?');if(a==true){ "+ result++ +"}; </script>");


您的脚本将在服务器上生成以下脚本并发送给客户端.在服务器上遇到result++时将对其进行评估.您的确认框仅在提示时起作用.您可能想使用隐藏变量或其他内容,然后通过脚本对其进行递增.


Your script will generate following script at server and send to client. result++ will be evaluated at its encounter on server itself. Your confirm box doesn''t serve anything but a prompt. You may like to use a hidden variable or something and increment it through your script.

<script>var a=confirm('You are about to change the shipping status of Order Id:! Are you sure you want to continue?');if(a==true){1}; </script>


这篇关于ASP .NET代码问题,小帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆