1.没有UpdatePanel时弹出对话框[C#] 纯文本查看 复制代码
/// <summary>
/// 弹出提示框
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="content">提示内容</param>
public static void Alert(Page page, string content)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script>alert('" + content + "');</script>");
}
2.没有UpdatePanel时弹出对话框并跳转
[C#] 纯文本查看 复制代码 /// <summary>
/// 弹出提示框并跳转页面
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="content">提示内容</param>
/// <param name="url">要跳转的页面</param>
public static void Alert(Page page, string content, string url)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "message", "<script>alert('" + content + "');location.href='" + url + "'</script>");
}
3.存在UpdatePanel时如何弹出对话框,两种方法(1.仅弹出 2.弹出并跳转),把页面的Updatepanel作为参数传值。
[C#] 纯文本查看 复制代码 /// 弹出提示框
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="panel">UpdatePanel名称</param>
/// <param name="content">提示内容</param>
public static void Alert(Page page, UpdatePanel panel, string content)
{
ScriptManager.RegisterStartupScript(panel, page.GetType(), "alert", "alert('" + content + "');", true);
}
/// 弹出提示框并跳转
/// </summary>
/// <param name="page">页面对象</param>
/// <param name="panel">UpdatePanel名称</param>
/// <param name="content">提示内容</param>
public static void Alert(Page page, UpdatePanel panel, string content, string url)
{
ScriptManager.RegisterStartupScript(panel, page.GetType(), "alert", "alert('" + content + "');location.href='" + url + "'", true);
}
|