ASP.NET如何实现页面间的参数传递
2006-07-26 14:52
218 查看
ASP.NET如何实现页面间的参数传递
一.使用QueryString 源页面代码:private void Button1_Click
(object sender, System.EventArgs e)
{
Response.Redirect("WebForm2.aspx?code="+this.TextBox1.Text+"&name="+this.TextBox2.Text); }
或在源页面.aspx文件中:
<script language="javascript">
function grdResult_CellClickHandler(gridName, cellId, button)
{
window.location="BOMItem.aspx?Code="+cell.Row.getCell(2).getValue();
}
</script>
目标页面代码:
private void Page_Load
(object sender, System.EventArgs e)
{
this.Label1.Text = "code:"+this.Request.QueryString["code"]+" and name:"+this.Request.QueryString["name"]; } 二.使用Session变量
源页面代码:
private void Button1_Click
(object sender, System.EventArgs e)
{
this.Session["code"] = this.TextBox1.Text;
this.Session["name"] = this.TextBox2.Text;
this.Response.Redirect("WebForm2.aspx"); }
目标页面代码:
private void Page_Load
(object sender, System.EventArgs e)
{
this.Label1.Text = "code:"+this.Session["code"].ToString() +" and name:"+ this.Session["name"].ToString();
this.Session.Remove("code");
this.Session.Remove("name"); } 三.使用Server.Transfer 源页面代码:
把以下的代码添加到页面中
public string code
{
get
{
return this.TextBox1.Text;
}
}
public string name
{
get
{
return this.TextBox2.Text;
}
}
然后调用Server.Transfer方法
private void Button1_Click
(object sender, System.EventArgs e)
{
Server.Transfer("WebForm2.aspx");
}
目标页面代码:
private void Page_Load
(object sender, System.EventArgs e)
{
WebForm1 wf1 = (WebForm1)Context.Handler;
this.Label1.Text = "code:"+wf1.code +" and name:"+ wf1.name;
}
相关文章推荐
- ASP.NET中实现页面间的参数传递 QueryString/Application/Session/Cookie
- ASP.NET中实现页面间的参数传递 QueryString\Application\Session\Cookie
- asp.net中页面间url参数传递的三种实现方法
- 在ASP.NET中实现页面间的参数传递【转】
- ASP.NET中实现页面间的参数传递 QueryString\Application\Session\Cookie (转载)
- 在ASP.NET中实现页面间的参数传递【转】
- ASP.NET中实现页面间的参数传递 QueryString/Application/Session/Cookie (转载)
- 在ASP.NET中实现页面间的参数传递
- 在ASP.NET中实现页面间的参数传递
- 【C#.NET】ASP.NET中实现页面间的参数传递 QueryString\Application\Session\Cookie
- asp.net如何实现不同页面之间的属性值传递
- 在ASP.NET中实现页面间的参数传递
- ASP.NET中实现页面间的参数传递
- ASP.NET中实现页面间的参数传递 QueryString/Application/Session/Cookie
- .net如何实现页面间的参数传递
- ASP.NET中实现页面间的参数传递
- 【C#.NET】ASP.NET中实现页面间的参数传递 QueryString\Application\Session\Cookie
- ASP.NET中实现页面间的参数传递 QueryString\Application\Session\Cookie
- asp.net传递的中文url参数在asp页面如何正确接收
- .net如何实现页面间的参数传递