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

推荐订阅源

T
Tenable Blog
H
Heimdal Security Blog
K
Kaspersky official blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
Schneier on Security
G
GRAHAM CLULEY
U
Unit 42
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
C
CERT Recently Published Vulnerability Notes
Google DeepMind News
Google DeepMind News
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
阮一峰的网络日志
阮一峰的网络日志
Simon Willison's Weblog
Simon Willison's Weblog
C
Cisco Blogs
Cyberwarzone
Cyberwarzone
T
The Exploit Database - CXSecurity.com
Project Zero
Project Zero
Security Archives - TechRepublic
Security Archives - TechRepublic
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - 司徒正美
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
V
Visual Studio Blog
博客园 - Franky
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
Jina AI
Jina AI
P
Proofpoint News Feed
P
Proofpoint News Feed
有赞技术团队
有赞技术团队
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
Spread Privacy
Spread Privacy
Application and Cybersecurity Blog
Application and Cybersecurity Blog
IT之家
IT之家
S
Security Affairs
博客园 - 叶小钗
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
N
News | PayPal Newsroom
Cloudbric
Cloudbric
AWS News Blog
AWS News Blog
W
WeLiveSecurity
The Last Watchdog
The Last Watchdog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
NISL@THU
NISL@THU

博客园 - Easy Company

如何取得显示实现方法的MethodInfo SQL Server 2008中许多兼容性上的问题 Mock 对象何时使用? ThreadPool 在.Net 2.0 SP1中的部分变化可能会让你的程序停止工作 目前不能使用SQL Server 2008 CTP February 2008存储Team Foundation Server 2008的数据 Javascript操作在各浏览器下的性能比较 WCF Web 编程模型资源 代码行数引起的思考 在按钮点击后禁用它直到操作完成 - Easy Company - 博客园 Silverlight 与 Microsoft ASP.NET Futures (July 2007) 更新 VS 2008 和.NET 3.5 Beta 2 安装注意事项 Partial Methods CIL(Common Intermediate Language)指令集 刚刚下载了 Visual Studio 2005 Service Pack 1 (SP1) 使用 Facade 设计模式管理 ASP.Net Session 变量 .Net 中的日志 使用 Membership 时获取用户的最后登录时间 How To 推荐用于 AJAX 页面的进度指示器图片
ASP.NET 2.0中使用强类型访问PreviousPage属性页的控件
Easy Company · 2007-09-21 · via 博客园 - Easy Company

ASP.NET 2.0 中增加了一个 IButtonControl 接口(ButtonImageButtonLinkButton控件实现了此接口),在这个接口中定义了一个 PostBackUrl 属性,使用这个属性可以实现在用户点击按钮时将页面的内容回发到另外一个页面。并且在另一个页面中可以使用 Page.PreviousPage 属性获取到前一个页面的实例,通过  PreviousPage.FindControl("ControlID") 方法获取前一页面中的控件以及控件的属性。然而,在你必须将控件从前一页的控件树中找出来才能访问控件的属性。

如果想直接访问那些属性,我们可以使用@ PreviousPageType 指令获取 PreviousPage 属性的强类型来实现。下面是一个例子:

Page1.aspx

<%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
><script runat="server">
    public string TextValue
    {
        get { 
return TextBox1.Text; }
    }

</script><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    
<title>无标题页</title>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
        
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        
<asp:Button ID="Button1" PostBackUrl="Page2.aspx"
            runat
="server" Text="Button" />
    
</div>
    
</form>
</body>
</html>

Page2.aspx

<%@ Page Language="C#" %>
<%@ PreviousPageType VirtualPath="~/Page1.aspx" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
><script runat="server">
    protected 
void Page_Load (object sender, EventArgs e)
    {
        
if (!IsPostBack)
            Label1.Text 
= PreviousPage.TextValue ;
    }
</script><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    
<title>无标题页</title>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
        Page1中输入的文本是:
       
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    
</div>
    
</form>
</body>
</html>

注意:只能在 Web 窗体页(.aspx 文件)上使用 @ PreviousPageType 指令。如果同时定义了属性 TypeNameVirtualPath,则 @ PreviousPageType 指令将失败。