button.attributes.add("onclick","if(confirm('are you sure...?')){return true;}else{return false;}")

解决方案 »

  1.   

    window.confirm('are you sure want to delete this record?')
      

  2.   

    button.attributes.add("onclick","return confirm(''are you sure...?')");
      

  3.   

    win还是web?
    如果是win 就很简单。
    如果是web就最好在html文件里写一个javascript函数来实现,很简单的,而且用起来也很方便,在CS文件里直接判断就可以了
      

  4.   

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function confirm_del()
    {
    if(window.confirm('are you sure want to delete this record?'))
    {return true;}
    else
    {return false;}
    }
    </SCRIPT>
    javascript函数这样写没错吧
           
    在vb里面:
    btDel.Attributes.Add("onclick", "JavaScript: return confirm_del();")
      

  5.   

    private void DataGrid2_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    e.Item.Cells[4].Attributes.Add("onclick","javascript: return confirm('确定要删除此项吗?');");
    }
    我这个是在DATEGRID中删除的时候的提示确认
      

  6.   

    同意 smoothwood(吾谁与归) 的办法
      

  7.   

    button.attributes.add("onclick","if(confirm('are you sure...?')){return true;}else{return false;}")
      

  8.   

    button.attributes.add("onclick","return confirm('')")
      

  9.   

    我把
    button.attributes.add("onclick","if(confirm('are you sure...?')){return true;}else{return false;}")
    写在后置代码的单击事件里,为什么总是第一次点击没反应,要点第二次才会弹出对话框啊
      

  10.   

    test.vb
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Button1.Attributes.Add("onclick", "if(confirm('are you sure...?')){return true;}else{return false;}")    End Sub
    为什么,总是第一次没反应,要第二次单击才弹出对话框
      

  11.   

    怎么回事,我怎么写都是不能弹出来呢?都试过了,如下所示:
        Public Sub btDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btDel.Click
            'btDel.Attributes.Add("onclick", "javascript: return confirm('确定要删除此项吗?');")
            btDel.Attributes.Add("onclick", "if(confirm('are you sure...?')){return true;}else{return false;}")
        end Sub