
asp.net代码练习 work012 继承BasePage,控制页面访问权限
发布日期:2021-05-06 21:17:41
浏览次数:12
分类:技术文章
本文共 1620 字,大约阅读时间需要 5 分钟。
basepage.cs
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Data;using System.Configuration;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;namespace work012{ public class BasePage :System.Web.UI.Page { public BasePage() { this.Load += new EventHandler(BasePage_Load); } protected void BasePage_Load(object sender, EventArgs e) { if (Session["UserName"] == null) { //Response.Redirect("Login.aspx"); Response.Write("无权限"); } } }}
login.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="work012.Login" %>
login.aspx.cs
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace work012{ public partial class Login : BasePage { private string date; protected void Page_Load(object sender, EventArgs e) { if (date == null) { date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } Response.Write("Time Now is " + date + ""); if (!IsPostBack) { Response.Write("第一次加载"); } else { Response.Write("回发加载"); } } protected void Button1_Click(object sender, EventArgs e) { } }}
发表评论
最新留言
很好
[***.229.124.182]2025年03月11日 23时35分52秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
【JokerのZYNQ7020】LINUX_EMIO_LED。
2019-03-03
【JokerのZYNQ7020】LINUX_EMIO_BUTTON。
2019-03-03
vim匹配特定的行并删除
2019-03-03
读取excel文件错误
2019-03-03
傅里叶变换的初级理解三
2019-03-03
F1 score的意义
2019-03-03
python36+centos7离线安装tensorflow与talib的方法
2019-03-03
hdf5与hdfs的区别
2019-03-03
scala运行的方式
2019-03-03
tf.Session().as_default的作用
2019-03-03
isnull与isna的区别
2019-03-03
python自带超参调优包
2019-03-03
判断python模型是否安装的办法
2019-03-03
xgboost与gbdt的区别
2019-03-03
软件测试中使用coverage统计python代码的覆盖率
2019-03-03
从double到float的强制类型转换
2019-03-03
C++ 任意数据类型转为16进制输出
2019-03-03
PYTHON UDP只能接收本地报文,无法接收其他主机通过路由器发过来的报文
2019-03-03
QLabel控件功能示例
2019-03-03
vue项目中报/sockjs-node/info错误
2019-03-03