日期:2014-05-18 浏览次数:20647 次
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.VisualBasic; using System.Xml; using System.Web.UI.HtmlControls; namespace CSDN { public class BasePage : System.Web.UI.Page { public BasePage() { } public string PageTitle { get { return Page.Title; } set { Page.Title = value; } } /// <summary> /// 出示话页面 /// </summary> /// <param name="e"></param> protected override void OnInit(EventArgs e) { object currentUser = Session["LoginName"]; if (currentUser == null) { MessageBoxAndRedirect("请重新登录", "../Longin/Longin.aspx", ""); } string cssUrl = "../_rec/css/base.css"; HtmlLink CssControl = new HtmlLink(); CssControl.Href = cssUrl; CssControl.Attributes.Add("rel", "stylesheet"); CssControl.Attributes.Add("type", "text/css"); Page.Header.Controls.Add(CssControl); cssUrl = "../_rec/css/layout.css"; CssControl = new HtmlLink(); CssControl.Href = cssUrl; CssControl.Attributes.Add("rel", "stylesheet"); CssControl.Attributes.Add("type", "text/css"); Page.Header.Controls.Add(CssControl); cssUrl = "../_rec/css/form.css"; CssControl = new HtmlLink(); CssControl.Href = cssUrl; CssControl.Attributes.Add("rel", "stylesheet"); CssControl.Attributes.Add("type", "text/css"); Page.Header.Controls.Add(CssControl); cssUrl = "../_rec/css/table.css"; CssControl = new HtmlLink(); CssControl.Href = cssUrl; CssControl.Attributes.Add("rel", "stylesheet"); CssControl.Attributes.Add("type", "text/css"); Page.Header.Controls.Add(CssControl); } /// 跳转父页面 /// </summary> /// <param name="AText">要显示的文本内容。</param> /// <param name="AUrl">警告框关闭后浏览器将要跳转的地址。</param> /// <remarks></remarks> public static void MessageBoxAndRedirect(string AText, string AUrl, string Top) { AText = FormatJScriptAlertText(AText); System.Web.HttpContext.Current.Response.Write("<script language='Javascript'>alert('" + AText + "');" + Constants.vbNewLine + "window.top.location.href ='" + AUrl + "';" + "</script>"); System.Web.HttpContext.Current.Response.End(); } /// <summary> /// 格式化 JScript 函数 Alert 中的文本为 HTML 格式。 /// </summary> /// <param name="AText">要格式化的 Alert 文本。</param> /// <returns>字符串。可以被 JScript Alert 函数正确显示的字符串。</returns> /// <remarks></remarks> public static string FormatJScriptAlertText(string AText) { string s = AText.Replace("\\", "\\\\"); s = s.Replace(ControlChars.CrLf, "\n"); s = s.Replace(Contro