弹出的选择是否在关闭当前页面的对话框,十分感谢
button_click(在button_click()
{
}
默认是关闭当前页面

解决方案 »

  1.   

    http://topic.csdn.net/u/20100818/10/56286851-e907-4a41-b896-ef9c9e621637.html
      

  2.   

    在ajax的updatepannel中这种方法不行,除非方到 updatepannel之外,上午已经试过了
      

  3.   

        protected void SysInfo()
        {
            ScriptManager.RegisterClientScriptBlock(UpdatePanel1, UpdatePanel1.GetType(), "SysInfo", "javascript:return confirm('你确认要删除)", true);
        }
      

  4.   

    this.ClientScript.RegisterStartupScript(this.GetType(),"ss","<script>alert('不能添加!');</script>");
    把这句改成
    ScriptManager.RegisterStartupScript((System.Web.UI.Page)HttpContext.Current.CurrentHandler, typeof(System.Web.UI.Page), "success", "<script>alert('不能添加!');</script>", false);
      

  5.   

    ScriptManager.RegisterStartupScript(this.UpdatePanel1,this.GetType(),"aa", "alert('保存成功')", true);这种事可以的,但是如何关闭当前页面?
      

  6.   

    前台:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ConfirmTest._Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
        <script>
            function MyConfirm() {
                if (confirm("确定要继续吗?") == true) {
                    document.getElementById("hidden1").value = "1";
                }
                else {
                    document.getElementById("hidden1").value = "0";
                }
                form1.submit();
            }
            function CloseCurrPage() {
                document.getElementById('hidden1').value = '0';
                
                if (confirm("确定要关闭当前页面吗?") == true) {
                    window.close();
                }
            }        
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <input type="hidden" id="hidden1" runat="server" />
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="测试Confirm" 
            onclick="Button1_Click" />
        </form>
    </body>
    </html>后台:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;namespace ConfirmTest
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (this.hidden1.Value == "1")
                {
                    this.MyGo();
                }
            }        protected void Button1_Click(object sender, EventArgs e)
            {
                //从数据库中取数据进行判断
                //这里简单的改为判断页面上的textbox
                if (this.TextBox1.Text == "1")
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(),"ss","<script>alert('不能添加!');</script>");
                    return;
                }
                else if (this.TextBox1.Text == "2")
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>MyConfirm();</script>");
                }
                else if (this.TextBox1.Text == "3")
                {
                    MyGo1();
                }
                else
                {
                    MyGo();
                }
            }        //需要继续执行的方法
            private void MyGo()
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>alert('"+this.hidden1.Value+"');document.getElementById('hidden1').value='0';</script>");
            }
            //需要继续执行的方法
            private void MyGo1()
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "ss", "<script>CloseCurrPage();</script>");
            }
        }
    }