你这个pF_Verify()方法没有带参数?而你这里return pF_Verify('txtName')是带参数的挖在JS那个方法里加上参数

解决方案 »

  1.   

    trycmdSave.Attributes.Add ("onclick","return pF_Verify('" + txtName + "')");
      

  2.   

    cmdSave.Attributes.Add ("onclick","return pF_Verify('txtName')");的话,参数是一个string,还有什么value属性?
      

  3.   

    是你的验证函数写错了
    你传的是字符串
    document.all(a[0]).Value == "")
      

  4.   

    呵呵,不好意思,参数是传错了,但是改过来了pF_Verify还是没有触发啊
      

  5.   

    你查看运行时候的网页的源代码,搜索pF_Verify
    看看生成的是什么东西
      

  6.   

    还有,这个你其实不用传递参数,直接这样写
    function pF_Verify()
    {
    var a= document.all.<%= txtName.ClientID %>.value;
    if (a == "")
    {
    alert("请输入姓名");
    return false;
    }
    else
    {
    return true;
    }
    }
    cmdSave.Attributes.Add ("onclick","return pF_Verify()");
    这样试试
      

  7.   

    if(!IsPostBack)
    {
    Button2.Attributes.Add("onclick","ClickButton2('TextBox1')");
    }----------------------
    script: function ClickButton2(c)
    {
    var txt = document.getElementById(c);
    var s = (eval(txt)).value;
    alert(s);
    if(s =="ok")
    {
    alert("ok");
    }
    else
    {
    return false;
    }
    }
      

  8.   

    改一下。private void Page_Load(object sender, System.EventArgs e)
    {
        //if (!Page.IsPostBack)
        //{ 
           cmdSave.Attributes.Add ("onclick","return pF_Verify('txtName')");
        //}
    }function pF_Verify(a)
    {
    aa=eval('document.表单名.' + a + '.Value'); 
    if (aa== ""))
    {
    alert("请输入姓名");
    return false;
    }
    else
    {
    return true;
    }
    }
      

  9.   

    To:brightheroes(闭关|那一剑的风情)
    在运行时有问题,提示我没有对象(pF_Verify).
    <TABLE id="tab1" style="Z-INDEX: 103; LEFT: 208px; WIDTH: 370px; POSITION: absolute; TOP: 16px; HEIGHT: 44px" cellSpacing="0" cellPadding="0" width="370" border="0">
    <TR>
    <TD style="WIDTH: 80px"><input type="image" name="cmdAdd" id="cmdAdd" src="img/add.gif" border="0" style="height:20px;width:72px;" /></TD>
    <TD><input type="image" name="cmdUpdate" id="cmdUpdate" src="img/Update.gif" border="0" style="height:20px;width:72px;" /></TD>
    <TD><input type="image" name="cmdDelete" id="cmdDelete" src="img/delete.gif" border="0" style="height:20px;width:72px;" /></TD>
    <TD><input type="image" name="cmdCancel" id="cmdCancel" src="img/Cancel.gif" border="0" style="height:20px;width:72px;" /></TD>
    <TD><input type="image" name="cmdSave" id="cmdSave" onclick="return pF_Verify()" src="img/Save.gif" border="0" style="height:20px;width:72px;" /></TD>
    </TR>
    </TABLE>
    以上是运行时生成的Html中片段
    最后一个<TD>那找不到pF_Verify
      

  10.   

    To  jiezhi(風依舊) :
    用你的能搞定,你能告诉我之前我的方法是不是触发不了pF_Verify?