Passing Values between ASP.NET Web Forms

Discussion in 'ASP.NET 2.0' started by srinivasv, Jul 2, 2011.

  1. For passing Values between ASP.NET Web Forms how to create the instance of Source.aspx page(Source WebForm) in Target.aspx(Target WebForm ) page

    Destination Web Form(Target.aspx.cs)

    Not-Working code is shown below:

    Code:
    private void Page_Load (object sender, System.EventArgs e)
    {
    	//create instance of source web form
    	WebForm1 wf1;//[COLOR="Red"]Problem here[/COLOR]
    	//get reference to current handler instance
    	wf1=(WebForm1)Context.Handler;
    	Label1.Text=wf1.Name;
    	Label2.Text=wf1.EMail;
    }
     
  2. The example you are using is from here:
    http://www.dotnetbips.com/articles/c585b4d3-93c5-4c66-9d49-8e1946f4d311.aspx

    To pull that off you have to be using the Server.Transfer method.
    As he mentions in that article it is "somewhat complex" to do.

    This MSDN article may help a bit:
    http://msdn.microsoft.com/en-us/library/aa713401(v=VS.71).aspx

    Personally I think the Query String method is a lot easier to work with:
    http://www.dotnetspider.com/resources/42759-Different-Methods-Pass-Values-between-Web-Forms.aspx
     

Share This Page