惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tenable Blog
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

博客园 - JoyBin

使用CSS为图片添加更多趣味的5种方法. IT工作者要保护自己的头发啊.. document.execCommand()用法说明 用三层架构与设计模式思想部署企业级数据库业务系统开发(转) C#代码与javaScript函数的相互调用 IE6 png 透明 (三种解决方法)(转) - JoyBin 程序人生就像一场恶梦。 常用正则表达式 [转载]Meta标签详解 三级联动-完美版 - JoyBin - 博客园 asp.net(C#)服务器绝对路径转换成URL相对路径[修改] (转) flash的菜单与asp.net进行交互(转) 把生成的缩略图存到数据库中 添加html内容(insertAdjacentHTML和insertAdjacentText) 常用.net代码 常用JS代码 SQLServer存储过程分页 WMPLib.WindowsMediaPlayer 的用法 网页播放器 PlayState 的用法
母版页判断登陆 及 母版页与内容页的执行顺序
JoyBin · 2008-04-18 · via 博客园 - JoyBin

在checkLogin.cs里有check方法:

public static void check(Page aPage)
    {
        if (aPage.Session["ok"] == null || aPage.Session["ok"].ToString() != "ok")
        {
            aPage.Response.Redirect("login.aspx");
        }
    }

在母版页里调用的正确方法:

protected void Page_Init(object sender, EventArgs e)
    {
        checkLogin.check(this.Page);
    }

原因:

母版页和内容页的执行顺序:

1.母版页中控件的Init;
2.内容页控件的Init;
3.母版页的Init;
4.内容页的Init;
5.内容页的Load;
6.母版页的Load;
7.内容页中控件的Load;
8.内容页的PreRender;
9.母版页的PreRender;
10.母版页控件的PreRender;
11.内容页中控件的PreRender

出错方法:

1、checkLogin.check(mypage);
运行:MasterPage类转Page类出错

2、Page mypage=new Page();
checkLogin.check(mypage);
运行:System.Web.HttpException: 响应在此上下文中不可用。

3、用户自定义控件MasterPublicMethod.ascx,调用检查方法
protected void Page_Load(object sender, EventArgs e)
    {
        checkLogin.check(this.Page);
    }
控件加入母版页:<uc1:MasterPublicMethod id="MasterPublicMethod1" runat="server"></uc1:MasterPublicMethod>
这个方法改成:在母版页的Page_Load事件里:checkLogin.check(this.Page);
运行:正常
出错原因:事件执行顺序:内容页的Page_Load事件->母版页的Page_Load事件,要在页面最开始检查有没有登录

4、母版页:
protected void Page_Load(object sender, EventArgs e)
    {
        //Response.Write("母版");
        checkLogin.check(this.Page);
    }
内容页的Page_LoadComplete事件:
protected void Page_LoadComplete(Object sender, EventArgs e)
    {
        int t, bid;
        //初始化自定义控件用的参数
        pg = Convert.ToInt32(Request.QueryString["pg"]);
        bid = Convert.ToInt32(Request.QueryString["id"]);
        t = Convert.ToInt32(Request.QueryString["t"]);
        switch (t)
        {
            case 1:
                //回复
                break;
            case 2:
                //修改回复
                break;
            case 3:
                //隐藏
                HideBook(bid);
                break;
            case 4:
                //删除
                DelBook(bid);
                break;
        }
    }
修改原因:页面执行顺序:内容页的Page_Load->母版页的Page_Load->内容页的Page_LoadComplete
运行:自定义控件里有变量未赋值出错
出错原因:有的内容页里有自定义控件,自定义控件的Page_Load事件里有代码,自定义控件的参数在内容页的Page_LoadComplete事件里初始化
Page_Load的执行顺序:内容Page_Load->母版Page_Load->自定义控件Page_Load->内容Page_LoadComplete