/// <summary> /// 弹出对话框(确定后页面会错位) /// </summary> /// <param name="TxtMessage"></param> /// <returns></returns> public string MessageBox1(string TxtMessage) { string str; str = "<script language=javascript>alert('" + TxtMessage + "')</script>"; return str; } /// <summary> /// 弹出对话框,不需要Response.Write(...) /// </summary> /// <param name="TxtMessage"></param> public void MessageBox(string TxtMessage) { Page page = (Page)HttpContext.Current.CurrentHandler; page.ClientScript.RegisterStartupScript(this.GetType(),"message","alert('" + TxtMessage + "')", true); }
/// <summary> /// 弹出框并跳转到指定页面 /// </summary> /// <param name="txtMessage">弹出框提示信息</param> /// <param name="url">要跳转到的地址</param> public void MessageBox(string txtMessage, string url) { Page page = (Page)HttpContext.Current.CurrentHandler; page.ClientScript.RegisterStartupScript(this.GetType(), "message", "alert('" + txtMessage + "');window.location='" + url + "'",true); }