RT:
protected void Button1_Click(object sender, EventArgs e)
        {
            if(this.TextBox1.Text == "0")
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "confirm", "if(window.confirm('" + "讀者張三 應繳逾期罰款 10 元,是否已經完成繳費?')){window.document.getElementById('" + Button2.ClientID + "').focus();window.document.getElementById('" + Button2.ClientID + "').click();}else{window.document.getElementById('" + Button3.ClientID + "').focus();window.document.getElementById('" + Button3.ClientID + "').click();}", true);
                return;
            }
            this.Label1.Text = "bbb";
        }        protected void Button2_Click(object sender, EventArgs e)
        {
            this.Label1.Text = "已繳";
        }        protected void Button3_Click(object sender, EventArgs e)
        {
            this.Label1.Text = "未繳";
        }
点击确认或取消 Button2和Button3服务器事件不执行

解决方案 »

  1.   

    这个直接用javascript控制就可以 为啥要放到updatepanel
      

  2.   


    主要是想弄明白在updatepanel里弹出确认取消执行相应的服务器事件
     if(this.TextBox1.Text == "0") 
    并不是次次都弹出来
      

  3.   

    断点调试却执行了后台代码 而updatepanel没有更新 需要修改哪里呢
      

  4.   

    把JS寫到JS文件中比較好看.并不是次次都弹出来就不清楚了,也許有些User沒開啟javascript。
      

  5.   

    这里有个confirm的例子,使用AjaxControlToolkit:
    http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ConfirmButton/ConfirmButton.aspx使用楼主的方法确实不能更新画面,已验证js执行了,并且Button2_Click、Button3_Click可以执行,但是画面不更新
    怀疑ajax机制与confirm冲突
      

  6.   

    已经搞定了Button2 Button3 放到updatepanel外面即可