Example of Server.Transfer and Context Handler

Discussion in 'ASP.NET' started by hanusoft, Sep 3, 2007.

  1. hanusoft

    hanusoft New Member

    Joined:
    Sep 3, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    This is an example of Server.Transfer and Context Handler. Through this we can get the multiple values of previous form.

    In this page we are displaying data from previous form. We can use this technique for multiple form registration form.

    Code (ContextParent.aspx.cs): -
    Code:
    private void Button1_Click(object sender,System.EventArgs e)
    {
    	Server.Transfer("ContextChild.aspx");
    }
    
    internal Hashtable Value
    {
    	get
    	{
    		Hashtable objHT = new Hashtable();
    		objHT["Name"]=TextBox1.Text;
    		objHT["FathersName"]= TextBox2.Text;
    		objHT["Address"] = TextBox3.Text;
    		return objHT;
    	}
    }
    Code (ContextChild.aspx.cs) :-
    Code:
    private void Page_Load(object sender, System.EventArgs e)
    {
    	// Put user code to initialize the page here
    	Hashtable objHT = new Hashtable(); 
    	if(!IsPostBack)
    	{
    		ContextParent ParentPage;
    		ParentPage = (ContextParent)Context.Handler;
    		objHT = ParentPage.Value;
    		Response.Write("<br><br>");
    		foreach(DictionaryEntry di in objHT)
    		{
    			Response.Write(di.Key +" : "+di.Value);
    			Response.Write("<br>");
    		}
    	}
    }
     
  2. adithespeedy

    adithespeedy New Member

    Joined:
    Jun 16, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    [/PHP]it was too good
    PHP:
     
  3. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    What exactly does Server.Transfer do?
     
  4. narayan

    narayan New Member

    Joined:
    Apr 9, 2008
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    I think server.transfer will avoid a round trip from client to server
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice