技术开发 频道

Asp.net页面之间如何大量的传送参数

  【IT168 技术文档】除了常用的Get,Post,Session,Application等页面间可传递参数的方法,还有新的方法,这应该是Asp.net独有的吧

  B页面取A页面的值

  页面A代码

  public partial class Default : System.Web.UI.Page

  {

  
protected void Page_Load(object sender, EventArgs e)

  {

  }

  
public string F

  {

  
get { return this.TextBox1.Text.ToString(); }

  
set { this.TextBox1.Text = value; }

  }

  
public string M

  {

  
get { return this.TextBox2.Text.ToString(); }

  
set { this.TextBox2.Text = value; }

  }

  
protected void Button1_Click(object sender, EventArgs e)

  {

  Server.Transfer(
"Default2.aspx");

  
// 注意下,地址栏没变

  
//用Response.Redirect不行……

  
//Response.Redirect("Default2.aspx");

  
//这的解释http://topic.csdn.net/t/20051227/21/4484983.html

  }

  }

 

  页面B的代码

  public partial class Default2 : System.Web.UI.Page

  {

  
protected void Page_Load(object sender, EventArgs e)

  {

  Default s;

  
if (Context.Handler is Default)

  {

  s
= (Default)Context.Handler;

  Label1.Text
= s.F + "---"+ s.M;

  }

  }

  }

 

  应该注意到,页面Default.aspx.cs本身就是一个类,这样的话可以在页面二中直接使用这个类,将页面一需要传递的参数封装一下,供外界访问。

0