.net上的JS调用按钮点击事件在后台

时间:2012-05-24 01:34:46

标签: javascript .net

问题是.Net上的JS调用按钮点击事件没有进入后台,而且出现错误。

C#

    <asp:Button ID="btnDelete" runat="server" Text="Delete" CssClass="btn" 
    OnClientClick="return dgvCheckhasChoiced();"/> 
    <asp:Button ID="btnTest" runat="server" Text="Test"  
    CssClass="btn" OnClick="btnDelete_Click"/>

JS代码

  if (canDelete) {
        alert(document.getElementById("<%=btnTest.ClientID %>").value);//Here has reutn
        document.getElementById("<%=btnTest.ClientID %>").click();
    //this code is run,but don't int the background 
    //经过此代码却没有进入后台方法点击事件
        msgboxShow('alert','Is Delete?',"alert('123');
        document.getElementById('<%=btnTest.ClientID %>').click();",1,1,'Warning');
        //return alert“123”,Move to next step can't  find the method
        //弹出了提示框“123”,进入到下一步却报找不到该方法
        //return confirm('确认删除?');//To simulate confirm effect 要模拟的confirm效果
        }
        else {
        msgboxShow('BeCareful','Please select at least one need to delete records!','',null,0,'Warning');
        //alert("Please select at least one need to delete records!");
         return false;

0 个答案:

没有答案