日期:2014-05-17  浏览次数:21022 次

ASP.NET 常用方法类 - PageBase 页面基类

?

ASP.NET 常用方法类 - PageBase 页面基类

转自:http://blog.csdn.net/liaolian9948/article/details/4987108

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace MyBlog.WEB
{
??? public class PageBase : System.Web.UI.Page
??? {
??????? /// <summary>
??????? /// MD5加密
??????? /// </summary>
??????? /// <param name="sInputString">需要加密的字符串</param>
??????? /// <returns>加密后字符串</returns>
??????? public static string HashString(string sInputString)
??????? {
??????????? return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sInputString, "MD5");
??????? }

??????? /// <summary>
??????? /// MessageBox提示框
??????? /// </summary>
??????? /// <param name="Message">提示信息</param>
??????? public void MsgBox(string Message)
??????? {
??????????? ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('" + Message + "');</script>");
??????????? return;
??????? }

??????? /// <summary>
??????? /// MessageBox提示并转向新页面
??????? /// </summary>
??????? /// <param name="Message">提示信息</param>
??????? /// <param name="URL">跳转的路径</param>
??????? public void MsgBox(string Message, string URL)
??????? {
??????????? ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('" + Message + "');window.location='" + URL + "';</script>");
??????????? return;
??????? }
??????? /// <summary>
??????? /// 弹出新窗口
??????? /// </summary>
??????? /// <param name="pagePath">页面路径</param>
??????? /// <param name="winName">新窗口名称</param>
??????? /// <param name="winWidth">新窗口宽度</param>
??????? /// <param name="winHeight">新窗口高度</param>
??????? public void openNewWin(string pagePath, string winName, int winWidth, int winHeight)
??????? {
??????????? ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>window.open('" + pagePath + "','" + winName + "','toolbar=no,menubar=no,titlebar=no,directories=no,resizable=no,scroll=yes,status=no,fullscreen=no,center=yes,width=" + winWidth + ",height=" + winHeight + "');</script>");
??????????? return;
??????? }

??????? /// <summary>
??????? /// 弹出模态窗口
??????? /// </summary>
??????? /// <param name="pagePath">页面路径</param>
??????? /// <param name="winWidth">窗口宽度</param>
??????? /// <param name="winHeight">窗口高度</param>
??????? public void openModelWin(string pagePath, int winWidth, int winHeight)
??????? {
??????????? string temp;
??????????? temp = @"<script language='javascript'>";
??????????? temp += (@"?? var sPath ='" + pagePath + "';");
??????????? temp += (@"???????? strFeatures ='dialogWidth=" + winWidth + "px;dialogHeight=" + winHeight + "px;center=yes;scroll=no;help=no;status: No';");
??????????? temp += (@"???????? var returnvalue = window.showModalDialog(sPath,'brower',strFeature