主要是设置PostBackUrl属性值,设置为你所需要跳转页面的名称("~/Default2.aspx"),然后再("~/Default2.aspx")页面中用PreviousPage.FindControl()方法找到所需要当前页的控件。

代码:

  Default.aspx:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>第一个页面</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
        <asp:Button ID="Button1" runat="server" Text="跳转" PostBackUrl="~/Default2.aspx" />
   
    </div>
    </form>
</body>
</html>

第二个页面的CS文件

Default2.aspx.cs:

protected void Page_Load(object sender, EventArgs e)
    {
        TextBox tex = (TextBox)PreviousPage.FindControl("TextBox1");
        Response.Write(tex.Text);
    }

  

posted on 2011-07-17 19:18  刁健  阅读(362)  评论(0编辑  收藏  举报