btn.Attributes.Add("onclick","return confirm('ok?')")

解决方案 »

  1.   

    你应在cs文件中page_load
    btn.attaibuate.add("onclick","window.alert('sss'");
      

  2.   

    将这个按钮的AutoPost=false
    btnDel.Attributes.Add("onClick","return confirm('Do you want to Delete record');");
    会弹出一个窗口,如果点确定就执行,点取消就不执行服务器端的事件
      

  3.   

    使用Button的PreRender事件。
    该事件发生在Click事件之前。 private void Button1_Click(object sender, System.EventArgs e)
    {
    this.Label1.Text = "按钮激活后台处理程序";
    } private void Button1_PreRender(object sender, System.EventArgs e)
    {
    this.Button1.Attributes.Add("onclick","return confirm('你要运行后台处理程序吗?');");
    }
      

  4.   

    btn.Attributes.Add("onclick")="javascript:return confirm('ok?')")
      

  5.   

    谢谢各位,可能大家还没明白我的意思
    用alert('ok')不行,按了确定还会继续执行
    用return confirm('ok')弹出窗口会出来2个按钮,按确定他还会继续执行
    我现在是要:没有弹出窗口,服务器端的事件就执行
    有弹出窗口,这个弹出窗口只是个提示,服务器端事件是不会执行的
      

  6.   

    没有弹出窗口,服务器端的事件就执行有弹出窗口,这个弹出窗口只是个提示,服务器端事件是不会执行的btn.Attributes.Add("onclick","if(满足条件)(confirm('ok?'); return false;)")
      

  7.   

    你可以在javascript中判断,是弹出alert('')还是提交:
    function button1_onclick(){
    if(....)
    alert('...')
    else{
    window.document.Form1.submit();
    }
      

  8.   

    我也明白了
    btn.Attributes.Add("onclick","if(不满足条件){alert'不满足条件';return false;}else return true;); 
      

  9.   

    用了这位大哥的 xaodoudou(我不想做潜水员)
    谢谢大家