会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
宜城小子’BLOG
给自己一个定位 — 关注技术、专注RIA!
博客园
首页
新随笔
联系
订阅
管理
[收藏]一个重写Page基类的例子
using
System;
using
System.Data;
using
System.Configuration;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
/**/
///
<summary>
///
BasePage 的摘要说明
///
</summary>
public
class
BasePage : Page
{
//
重写Page OnPreInit事件
protected
override
void
OnPreInit(EventArgs e)
{
base
.OnPreInit(e);
//
如果是登陆页面,取消登陆验证
if
(GetRequestFilename().Equals(
"
Mes_Login.aspx
"
))
{
goto
Finish;
}
//
开始页面登陆验证
bool
isLog
=
false
;
try
{
isLog
=
Session[
"
LOGIN_FLAG
"
].ToString().Equals(
"
1
"
);
}
catch
(Exception ex)
{ }
if
(
!
isLog)
{
Alert(
"
您还未登录
"
);
Response.Redirect(
"
~/Mes_Login.aspx?ReturnUrl=
"
+
Request.RawUrl);
}
Finish:
{ }
}
/**/
///
<summary>
///
在页面弹出提示框(集成于基类BasePage)
///
</summary>
///
<param name="msg">
在提示框中显示的内容
</param>
public
void
Alert(
string
msg)
{
this
.RegisterClientScriptBlock(
"
js
"
,
"
<script>alert('
"
+
msg
+
"
')</script>
"
);
}
/**/
///
<summary>
///
在页面弹出提示框(静态型)
///
</summary>
///
<param name="msg">
在提示框中显示的内容
</param>
public
static
void
Alert(Page pg,
string
msg)
{
pg.RegisterClientScriptBlock(
"
js
"
,
"
<script>alert('
"
+
msg
+
"
')</script>
"
);
}
/**/
///
<summary>
///
取得当前Request Url的文件名称
///
</summary>
///
<returns>
返回当前Request Url的文件名称
</returns>
public
string
GetRequestFilename()
{
return
System.IO.Path.GetFileName(Request.Path);
}
}
本文来自CSDN博客:
http://blog.csdn.net/Flyear_cheng/archive/2008/05/22/2468928.aspx
posted @
2009-07-07 13:37
宜城小子
阅读(
459
) 评论(
0
)
收藏
举报
刷新页面
返回顶部
公告