public static class PageExtens
{
/// <summary>
/// 服务器端弹出alert对话框
/// </summary>
/// <param name="page">Page类</param>
/// <param name="str_Message">提示信息</param>
public static void Alert(this Page page, string str_Message)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "", "<script>alert('" + str_Message + "');</script>");
}
/// <summary>
/// 服务器端弹出alert对话框
/// </summary>
/// <param name="page">Page类</param>
/// <param name="str_Message">提示信息</param>
/// <param name="str_CtlNameOrPageUrl">获取焦点控件的Id值</param>
public static void Alert(this Page page, string str_Message, string str_CtlNameOrPageUrl)
{
if (str_CtlNameOrPageUrl.IndexOf(".") >= 0)
{
page.ClientScript.RegisterStartupScript(page.GetType(), "", "<script>alert('" + str_Message + "');self.location='" + str_CtlNameOrPageUrl + "';</script>");
}
else
{
page.ClientScript.RegisterStartupScript(page.GetType(), "", "<script>alert('" + str_Message + "');document.forms(0)." + str_CtlNameOrPageUrl + ".focus();document.forms(0)." + str_CtlNameOrPageUrl + ".select();</script>");
}
}
}