中国站长下载-为中国站长提供最好最全的建站资源! 首 页发布资源有事留言繁體中文
设为首页
加入收藏
联系我们
 
您当前的位置:中国站长下载 -> 文章中心 -> 网页编程 -> .NET编程 -> 文章内容  虚拟主机 域名注册 退出登录 用户管理
栏目导航
· ASP编程 · .NET编程
· PHP编程 · JSP编程
· CGI 专区
热门文章
· sndvol32 - sndvol3...
· [组图] FLASH:《大话李白》...
· 个人网站到底能赚多...
· [图文] Rundll.exe是病毒吗...
· [组图] Flash:制作MV
· 价值12万元的网站SE...
· 网站创业者,你需要...
· 一个成功的网站设计...
· [图文] FLASH:韩国导航条解...
· 中国网站的赚钱模式...
相关文章
2个页面间不通过Session与url的传值方式
作者:不详  来源:不详  发布时间:2006-8-14 8:46:04  发布人:chinazhan

 减小字体 增大字体

     下面是全部代码,已经编译通过。
  Chuandi(传递)是名字空间
  
  WebForm1:
  <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" Inherits="chuandi.WebForm1" %>
  <HTML>
   <HEAD>
   <title>WebForm1</title>
   </HEAD>
   <body>
   <form id="Form1" method="post" runat="server">
   <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
   <asp:Button id="Button1" runat="server" Text="传"></asp:Button>
   </form>
   </body>
  </HTML>
  using System;
  namespace chuandi
  {
   public class WebForm1 : System.Web.UI.Page
   {
   protected System.Web.UI.WebControls.TextBox TextBox1;
   protected System.Web.UI.WebControls.Button Button1;
   public string Text1
   {
   get
   {
   return this.TextBox1.Text;
   }
   }
   private void Page_Load(object sender, System.EventArgs e)
   {}
   override protected void OnInit(EventArgs e)
   {
   InitializeComponent();
   base.OnInit(e);
   }
   private void InitializeComponent()
   {
   this.Button1.Click += new System.EventHandler(this.Button1_Click);
   this.Load += new System.EventHandler(this.Page_Load);
   }
   private void Button1_Click(object sender, System.EventArgs e)
   {
   Server.Transfer("WebForm2.aspx");
   }
   }
  }
  
  
  WebForm2:
  <%@ Page language="c#" Codebehind="WebForm2.aspx.cs" Inherits="chuandi.WebForm2" %>
  <%@ Reference Page="WebForm1.aspx" %>
  <HTML>
   <HEAD>
   <title>WebForm2</title>
   </HEAD>
   <body>
   <form id="Form1" method="post" runat="server">
   <asp:Label id="Label1" runat="server">Label</asp:Label>
   <asp:Button id="Button1" runat="server" Text="返回"></asp:Button>
   </form>
   </body>
  </HTML>
  using System;
  namespace chuandi
  {
   public class WebForm2 : System.Web.UI.Page
   {
   protected System.Web.UI.WebControls.Button Button1;
   protected System.Web.UI.WebControls.Label Label1;
   public chuandi.WebForm1 wf1;
   private void Page_Load(object sender, System.EventArgs e)
   {
   if(!IsPostBack)
   {
   wf1=(chuandi.WebForm1)Context.Handler;
   Label1.Text="上页传来的是:"+wf1.Text1;
   }
   }
   override protected void OnInit(EventArgs e)
   {
   InitializeComponent();
   base.OnInit(e);
   }
   private void InitializeComponent()
   {
   this.Button1.Click += new System.EventHandler(this.Button1_Click);
   this.Load += new System.EventHandler(this.Page_Load);
   }
   private void Button1_Click(object sender, System.EventArgs e)
   {
   Server.Transfer("WebForm1.aspx");
   }
   }
  
  
    做人要厚道,请注明转自chinazhan中国站长(www.ChinaZhan.com)。

 
[] [返回上一页] [打 印] [收 藏]
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
中国站长下载
中国站长下载

本页只接受PR>=4 IT类站点连接,申请连接,谢谢您们的支持!希望我们的下载站能够真正帮到中国的站长们!
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图
Copyright © 2005-2006 ChinaZhan.Net. All Rights Reserved .