想实现这样的功能
protected void btnOK_Click(object sender, ImageClickEventArgs e) 

  ... 
  if (b>0) 
  { 
  弹出yes,no对话框 
    选择yes-->转到另外一个页面} 
  选择no-->继续代码 
  } 
... 

可以实现吗?
发现用JS的框框实现不了这样的呀,你碰到是怎么做的

解决方案 »

  1.   

    这是个服务器端按钮控件,在后台实现有点难度
    建议还是将逻辑尽量写道javascript中,即在Aspx页来实现逻辑,
    btnOK控件的onclientclick事件对应的return test()function test()
    {
        if(confirm("ok"))
        {
           //
         }
         else
         {     }
    }
    //if (b>0)
    估计此处变量b比较重要,因此,想办法将变量b的值,放到一个hidden控件当中,这样jacascript也能够读这个值了
      

  2.   

    RegisterStartupScript("ok","<script>if(confirm('提示信息')){ window.location.href='页面';} else {}</script>") ;
      

  3.   

     因为b/s的交互是通过http协议在两个不同的计算机这间进行的,
    如果要实现这种功能,只能模拟在btnOK的客户端函数中
    if(b>0)// b可从服务器首次载入时取得(如果是动态,可用ajax)
    {
     if(confirm("aa"))
     { 
            window.location = "另一个页面"
          }else
    {
     document.getElementById("Button1").clcik();//提交页面,执行button1_click的代码}
    }
      

  4.   

    如果我b>0的这种条件必须是按钮按钮才可以得到的是不是就更不好实现了呀!
    是不是要抛弃系统的CONFIRM框,自己用DIV层去做一个
      

  5.   

    谁自己弄过个这么样个控件带 YES和NO的呢?
      

  6.   

    应该没的问题
    <script>
            function alerts()
            {
              var b = document.getElementById("txtTest").value; 
              alert(b)
              if(b>0)
              {
                if(window.confirm())
                {
                
                    window.location.href="http://www.baidu.com"
                }
                else
                {
                    window.location.href="http://www.google.com"
                }
              }
            }
        </script>
            <input type="text" id="txtTest" />
            <input type="button" onclick="alerts();" value="text" />
      

  7.   

    不好意思,
    看错了。
    以为客户端服务器端可以的protected void btnOK_Click(object sender, ImageClickEventArgs e) 
    {  
      //b = this.TextBox1.Text  if (Convert.ToInt32(this.TextBox1.Text) > 0)
            {
                this.Page.ClientScript.RegisterStartupScript(typeof(string),"onclick", "<script>alerts();</script>");
            }
            else
            {
                return;
            }
    } 客户端JS function alerts()
            {
                if(window.confirm())
                {
                
                    window.location.href="http://www.baidu.com"
                }
                else
                {
                    window.location.href="http://www.google.com"
                }
           
            }测试成功
      

  8.   

    应该没的问题 
    <script> 
            function alerts() 
            { 
              var b = document.getElementById("txtTest").value; 
              alert(b) 
              if(b>0) 
              { 
                if(window.confirm()) 
                { 
                
                    window.location.href="http://www.baidu.com" 
                } 
                else 
                { 
                    window.location.href="http://www.google.com" 
                } 
              } 
            } 
        </script> 
            <input type="text" id="txtTest" /> 
            <input type="button" onclick="alerts();" value="text" /> 
      

  9.   

     public static void Confirm(string strMessage, string strOkPage, string strCancelPage, System.Web.UI.Page Page)
            {
    if (strCancelPage == null || strCancelPage.Length == 0)
    {
    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ConfirmMessage", "<script language=javascript> if (confirm('" + strMessage + "')==true){location.href='" + strOkPage + "';}</script>");

                
    }
    else
    {
    Page.ClientScript.RegisterStartupScript(Page.GetType(), "ConfirmMessage", "<script language=javascript> if (confirm('" + strMessage + "')==true){location.href='" + strOkPage + "';}else{location.href='" + strCancelPage + "';}</script>");


    }
            }