소프트웨어/C# & ASP.NET

하나의 클래스를 통째로 넘기는 방법 ( a.aspx.cs -> b.aspx.cs )

falconer 2008. 8. 28. 08:25
A.aspx.cs
------------------------------------------------------------
public partial class A : System.Web.UI.Page
{
    public string strTest { get { return "123"; } }
   protected void Page_Load(object sender, EventArgs e)
    {
   }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Server.Transfer("test2.aspx");
    }
}


B.aspx.cs

------------------------------------------------------------------------

public partial class B: System.Web.UI.Page
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
        A a = (A)Context.Handler;

        Response.Write(a.strTest);        

    }
}

---------------------------------------------------------------------

출처 : http://hoons.kr/Board.aspx?Name=QAASPNET&Mode=2&BoardIdx=14931&Key=&Value=