double total2; 
            if (total < 20) 
            { 
                total2 = total + 5; 
                RegisterStartupScript("yesorno", " <script>if(confirm('您的定单为不够20元,需加收5元送货费,是否继续订购'));else history.go(-1);document.getElementById('fan').click(); </script>"); 
            } 
            else 
            { 
                total2 = total; 
            } 
            string name = this.lblName.Text; 
            string logintime = Session["time"].ToString(); 
            string sendtime = this.txtOrderMealDateTime.Text; 
            string buytime = DateTime.Now.Date.ToString(); 
total获取的代码就不贴了,如果total <20时,弹出确定取消框,点击取消时,是返回当前页了,但是程序还是向下执行 
            string name = this.lblName.Text; 
            string logintime = Session["time"].ToString(); 
            string sendtime = this.txtOrderMealDateTime.Text; 
            string buytime = DateTime.Now.Date.ToString(); 
了,请教怎样能返回页后不执行下面的代码 

解决方案 »

  1.   


    double total2; 
                if (total < 20) 
                { 
                    total2 = total + 5; 
                    RegisterStartupScript("yesorno", " <script>
                if(confirm('您的定单为不够20元,需加收5元送货费,是否继续订购'))
                { 
                string name = this.lblName.Text; 
                string logintime = Session["time"].ToString(); 
                string sendtime = this.txtOrderMealDateTime.Text; 
                string buytime = DateTime.Now.Date.ToString(); 
                }
                else 
                {
                 history.go(-1);document.getElementById('fan').click();
                } 
                </script>"); 
                } 
                else 
                { 
                    total2 = total; 
                    string name = this.lblName.Text; 
                    string logintime = Session["time"].ToString(); 
                    string sendtime = this.txtOrderMealDateTime.Text; 
                    string buytime = DateTime.Now.Date.ToString(); 
                } 
      

  2.   

    我也是这样想的,放到else里就不会走了吗~
      

  3.   

    history.go(-1);document.getElementById('fan').click(); //这一段好像无效果了。如果某些机器反应够快
      

  4.   

      RegisterStartupScript("yesorno", " <script>
                if(confirm('您的定单为不够20元,需加收5元送货费,是否继续订购'))这么直接换行报错怎么办
      

  5.   

     RegisterStartupScript("yesorno", " <script> 
                if(confirm('您的定单为不够20元,需加收5元送货费,是否继续订购')) 原来是RegisterStartupScript("yesorno", " <script>if(confirm('您的定单为不够20元,需加收5元送货费,是否继续订购'));else history.go(-1);document.getElementById('fan').click(); </script>"); 写在一行里的
    3楼的写法
    在RegisterStartupScript("yesorno", " <script>处换行的话报错,请教高手应该怎么写
      

  6.   

    double total2; 
                if (total < 20) 
                { 
                    total2 = total + 5; 
                    RegisterStartupScript("yesorno", " <script>if(confirm('您的定单为不够20元,需加收5元送货费,是否继续订购'));else history.go(-1);document.getElementById('fan').click(); </script>"); 
                return;                                           //这个地方加 return;  就可以了
                } 
                else 
                { 
                    total2 = total; 
                } 
                string name = this.lblName.Text; 
                string logintime = Session["time"].ToString(); 
                string sendtime = this.txtOrderMealDateTime.Text; 
                string buytime = DateTime.Now.Date.ToString(); 
    total获取的代码就不贴了,如果total <20时,弹出确定取消框,点击取消时,是返回当前页了,但是程序还是向下执行 
                string name = this.lblName.Text; 
                string logintime = Session["time"].ToString(); 
                string sendtime = this.txtOrderMealDateTime.Text; 
                string buytime = DateTime.Now.Date.ToString(); 
    了,请教怎样能返回页后不执行下面的代码 
      

  7.   

     RegisterStartupScript("yesorno", " <script>if(confirm('您的定单为不够20元,需加收5元送货费,是否继续订购'));else history.go(-1);document.getElementById('fan').click(); </script>"); 
                return;  在这加return 点确定也返回
      

  8.   

    if(confirm('您的定单为不够20元,需加收5元送货费,是否继续订购'));else history.go(-1);document.getElementById('fan').click(); 
    仔细看了下,你是不是js都报错了呢?
    怎么看你的JS写得都不规距。