我的按钮是服务端控件,点击首先让用户确认是否提交,如果是继续执行,如果否什么都不作
我要求的地提示内容是个变量,也就是说我的提示内容一定是在后台写的,弹出的对话框也是在后台弹出的

解决方案 »

  1.   

    vS2005以上版本直接在你的控件属性处加OnClientClick="return confirm('确定?')"
      

  2.   

    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "<script>confirm('确定!')</script>",false);
    Response.Write"<script>confirm('确定!')</script>");  
    在gridview 中的 RowDataBound  事件中处理
        //删除事件
        protected void gvDepart_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ImageButton imgbtnDelete = e.Row.FindControl("imgbtnDelete") as ImageButton;
                imgbtnDelete.Attributes.Add("onclick", "return confirm('你确定要删除吗?')");        }
        }
      

  3.   

     <asp:Button ID="Button2" runat="server" Height="35px" Text="删 除" OnClick="Button2_Click" OnClientClick="return confirm('您确认删除该记录吗?');" />
      

  4.   

    更正下
    ScriptManager.RegisterStartupScript(this, this.GetType(), "", " <script>confirm('确定!');</script>",false); 
    Response.Write("<script>confirm('确定!');</script>");  
      

  5.   

    ”我要求的地提示内容是个变量“ 你可以把它设为public类型的 
    然后在前台用js判断
      

  6.   

    页面前台加个hidden 页面后台把得到提示内容放入hidden中
    页面后台加按钮ID.Attributes.Add("onclick","return check();");页面前台加function check(){
      var content = doccument.getElementById(hidden的ID).value
      return window.confirm("content确定?")
    }
      

  7.   

    OnClientClick="return confirm('确定?')"
    每天回帖即可获得10分可用分!
      

  8.   

    ScriptManager.RegisterStartupScript(this, this.GetType(), "", " <script>confirm('确定!') </script>",false);
    变量啦。,什么啦  都可以写的
      

  9.   

    这个的扩展性应该够 了 <form id="form1" runat="server">
        <div>
        <script>
        function aa()
        {
        var t =document .getElementById ("s");
        var cue=document .getElementById ("cue").value ;
           if (confirm(cue)==true) 
                        t.value ="true";
                              else
                                 t.value ="false";    }
        </script>
        <script runat=server >
        
            protected void Page_Load(object sender, EventArgs e)
            {
                Button1.Attributes.Add("onclick", "aa()");
            }        protected void Button1_Click(object sender, EventArgs e)
            {
                if (s.Value == "true")
                {
                    Response.Write("true");
                }
                else
                {
                    Response.Write("f");
                }
            }
        </script>
        <input type =hidden runat =server  id=s/>
        输入要弹出的值:<input type =text runat =server id=cue />
            <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
        </div>
        </form>
      

  10.   

    请问14楼 我能在Button1的点击事件里把参数显示在confirm上吗?
      

  11.   

    这是放汉字,
                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('没有选择图片');</script>");这是放变量的  this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('“+变量名+”');</script>");
      

  12.   


    var c =confirm(" ");
      

  13.   

    this.Page.ClientScript 是不是vs2005之后才有的?
      

  14.   

    JIN OK 
    不能在BUTTON1中来指定参数,因为 Button1.Attributes.Add("onclick", "aa()"); 这个在BUTTON1事件之前执行,你要显示的值要在事件发生前指定,把type =text -->type=hidden 在BUTTON1按钮事件前给个值就行,