如何在使用了updatepanel后弹出提示信息

时间:2023-03-08 22:30:41
如何在使用了updatepanel后弹出提示信息

转载:http://www.cnblogs.com/brusehht/archive/2009/03/19/1416802.html

常情况下,我们在使用ajax利用updatepanel实现页面局部刷新时需要有提示信息,而传统的方式是利用

Page.ClientScript.RegisterStartupScript来注册客户端脚本实现信息提示,但这种方式在ajax中不起作用,必须选择

System.Web.UI.ScriptManager.RegisterStartupScript来替代Page.ClientScript.RegisterStartupScript

例子.

System.Web.UI.ScriptManager.RegisterStartupScript(this.updatepanel1, this.GetType(), "unReport", "alert('保存成功!');window.close();", true);
下面给出一个函数用于实现弹出提示信息:
public static void Show(System.Web.UI.UpdatePanel updatePanel, string msg)
{
ScriptManager.RegisterStartupScript(updatePanel, updatePanel.Page.GetType(), "message", "alert('" + msg.ToString() + "');", true);
//page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<mce:script language='javascript' defer><!--
alert('" + msg.ToString() + "');
// --></mce:script>");
}