Server.Transfer 页面传输

来源:互联网 发布:psa中国技术中心 知乎 编辑:程序博客网 时间:2024/06/05 14:55

SiteA c# code

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

    {

        protected string datafrom_SiteA;



        protected void Page_Load(object sender, EventArgs e)

        {

            datafrom_SiteA = "this is the data from SiteA";

            Server.Transfer("SiteB.aspx");

        }



        public string getData()

        {

            return datafrom_SiteA;

        }

    }
SiteB C# code     源文件中加入<%@ PreviousPageType VirtualPath="~/SiteA.aspx" %>

public partial class Default4 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Default3 d3 = this.PreviousPage as Default3;

        Response.Write(d3.getData());
    }
}

 

原创粉丝点击