分类: 系统运维
2009-10-12 13:37:11
---------------------------------------------------------------------------------------------------
*QueryString pass data*
源页面:
private void PassData_Click(object sender, System.EventArgs e)
{
string URL="http:\\localhost\\anotherwebform.aspx?name=" +TextName.Text+ "&email=" +TextEmail.Text;
Response.Redirect(URL);
}
目标页面:
private void Page_Load(object sender, System.EventArgs e)
{
NameText.Text=Request.QueryString["name"];
EmailText.Text=Request.QueryString["email"];
}
---------------------------------------------------------------------------------------------------
*Session pass data*
源页面:
private void PassData_Click(object sender, System.EventArgs e)
{
Session["name"]=TextName.Text;
Session["phone"]=TextPhone.Text;
Server.Transfer("anotherwebform.aspx");
}
目标页面:
private void Page_Load(object sender, System.EventArgs e)
{
NameText.Text=Session["name"].ToString();
PhoneText.Text=Session["phone"].ToString();
}
---------------------------------------------------------------------------------------------------
*Server.Transfer pass data*
源页面WebForm1:
public string name//创建WebForm1返回值的get属性过程
{
get{return TextName.Text}
}
目标页面WebForm2:
WebForm1 wf1=new WebForm1();//创建WebForm1的对象
wf1=(WebForm1)Context.Handler;//通过Context.Handler来获得对前一页面WebForm1的引用
LabelName.Text=wf1.name;
---------------------------------------------------------------------------------------------------