Button2.Attributes.Add("onclick","return button2_click();");
这一句是否放在 page_load中

解决方案 »

  1.   

    是啊!问题是
    fuction button2_click()
    {
       return confirm("...");
    }
    就有反应了
    是不是
    if(IsEmpty(cart.TextBox2.value))
        {
          alert("....");
           return false;
        }
       else
          return confirm (".....");
    写错了啊,我不懂javascript
    谢谢指点!!
      

  2.   

    你这个函数应该是实现空校验的吧,我给一段我的函数你,alert("....");应该是用单引号不是用双引号,先是html页面那里写(Form1send为form的id txt_idinput为textbox的id) function get_html()
    {

    if(document.Form1send.txt_idinput.value=='' )   
    {
    alert('id不能空')

    return false;
    }
    else
    {
    return true;
    }

    }
    然后在pageload事件上写
       btnsend.Attributes("onclick") = "return get_html();"
      

  3.   

    你的txt_idinput不是web控件吧,而是html控件吧?
    好象web控件不能这样啊!
    不知道该怎么写啊?
      

  4.   

    1.没有IsEmpty,js编译出错
    解决方法:
    function IsEmpty(str){
    return str.replace(/(^\s*|\s*$)/g,"")==""
    }
    2.没有设置CausesValidation="false"
    Validation和onclick冲突
    解决方法:
    function document.all.Button2.onclick(){
    return button2_click();
    }