方法有两种。假设有Page1,Page2;Page2需要处理Page1控件的属性
第一种:用FindControl
假设Page1有控件Textbox
那么在Page2.aspx里
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Page2.aspx.cs" Inherits="Page2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e)
{
TextBox tb;
tb = (TextBox)PreviousPage.FindControl("TextBox1");
Label1.Text = "Hello " + tb.Text + "<br />"
}
</script>
第二种
public TextBox tb
{
get
{
return TextBox1;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage!=null)
{
if(PreviousPage.IsCrossPagePostBack==true)
Label1.Text = "Hello " + PreviousPage.tb.Text;
}
else
{
Response.Redirect("Page2.aspx");
}
具体可以见http://activer.cnblogs.com/archive/2006/03/16/351274.html