解决在Ajax更新面板下弹不出对话框的现象

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //页面加载弹出对话框
            OpenDialogForPage((Page)sender, "打开页面我就出来啦");
        }
    }

    protected void Button1_Click(object sender, ImageClickEventArgs e)
    {
        ///弹出按钮的对话框,如果是ImageButton或LinkButton之类的其他控件,
        ///就把代码中的Button对象改成相应的对象就行了
        OpenDialogForButton((Button)sender, "这是Button按钮弹出的提示对话框");
    }

    /// 
    /// 在ASP.NET AJAX环境中,为Button控件弹出一个提示对话框
    ///  
    /// Button控件 
    /// 对话框中的消息 
    private void OpenDialogForButton(Button button, string message)
    {
        //这里触发弹出框的控件是ImageButton,如果想要改成Button的话把ImageButton改成Button就可以了
        ScriptManager.RegisterClientScriptBlock(button, typeof(Button), DateTime.Now.ToString().Replace(":", " "), "alert('" + message + "')", true);
    }

    /// 
    /// 在ASP.NET AJAX环境中,为Page对象弹出一个提示对话框
    ///  
    /// Page对象 
    /// 对话框中的消息 
    private void OpenDialogForPage(Page page, string message)
    {
        ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), DateTime.Now.ToString().Replace(":", " "), "alert('" + message + "')", true);
    }  

}

你可能感兴趣的:(解决在Ajax更新面板下弹不出对话框的现象)