<button onclick="if(confirm('是否连接')){window.open('http://aspx.cc','_self')}") ID="Button1">连接</button>

解决方案 »

  1.   

    botton1.Attributes.Add("onclick", "return confirm('您确定要删除');")
      

  2.   

    onclick函数是自定义的要执行的操作吗?为什么我点确定后没有反应?
      

  3.   

    onclick是按钮的点击事件,先执行了javascript,然后再执行你的cs或者vb.net代码
    你的button OnClick事件后的代码是什么呢?
      

  4.   

    btn1.Attributes.Add("onclick", "return confirm('您确定要操作?);")
      

  5.   

    这是Button1的点击事件
    private void Button1_Click(object sender, System.EventArgs e)
    {
         Response.Write("nihao");
    }
    Page_Load函数中这么写:
    Button1.Attributes.Add("OnClick", "return confirm('您确定要操作?);");
    不能正确运行,为什么?
      

  6.   

    原因很简单:
    Button1.Attributes.Add("OnClick", "return confirm('您确定要操作?);");
    少了个单引号:
    Button1.Attributes.Add("OnClick", "return confirm('您确定要操作?');");