上一篇:分享:aspx页面javascript的几个trick >>
2个页面间不通过Session与url的传值方式
下面是全部代码,已经编译通过。
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");
}
}
下一篇:Solidworks二次开发—09--添加配合参考 >>
相关文章:
- · datagrid编辑删除分页
- · 展现C# 清单5.10 生成exe文件执行的问题
- · 联通增值业务“定位之星”L1协议服务端的模拟器
- · 一个自认为写得还可以的存储过程,就是没有注释,看起来有点乱。与ERP的BOM相关的
- · [EnterpriseServices]利用assembly定义我们的组件在COM+中的注册方式
- · 给windows服务添加描述
- · 用户认证管理设计方案
- · Solidworks二次开发—07—控制草图对象
- · 数据库事务处理的另外一种方法
- · 《Essential .Net》读书笔记 - Chapter 3
- · DX图形显示基本流程(基于MESH静态模型绘制----托管代码)
- · 如何让 DevExpress 的 DateEdit 控件正确显示日期的周名
- · ASP.net下的前台日历控件源代码(不刷新页面)
- · 通过可视化继承和页面模板控制站点设计
- · 在ASP.Net中两种利用CSS实现多界面的方法
- · 数据表单向导的快速实现
- · Posting form data from ASP.NET page to another URL
- · Asp.net中Treeview终极解决方案
- · 解决ASP.NET创建的线程的用户改变引发的拒绝访问错误
- · 有关sql注入
- · 一个动态编译的例子
- · 一个拷贝整个文件夹(包括子文件夹)的方法(原创)
- · 在ASP.NET中实现弹出日历
- · 在DataGrids和DropDownLists中使用ADO
- · asp.net 页面中生成 RSS 2.0 提要
- · Session登陆后丢失的解决办法
- · 基于HTTP协议用WinSock实现任意文件下载
- · 奔腾Flash Player source code
- · 《Essential .Net》读书笔记 - Chapter 2
- · 《Essential .Net》读书笔记 - Chapter 1
- · 获取指定IP的终端的MAC地址
- · 网络传输(FTP)问题
- · Paint.NET: An Open Source GDI+ App Likes Photoshop
- · 看到有人用 WebClient来下载, 发篇用 WebRequest 实现有进度下载的吧.
- · 树形控件TreeView的序列化
- · 使用javascript+XML实现分页
- · 使用Control.Invoke处理多线程应用程序界面
- · WEB页面TreeView的应用-(得到所有选中的节点)
