Passing data from onepage to another we use Server.Transfer and other method. Server.Transfer isprovide more efficient result as comparison to other.

“The Page representing the page thattransferred control to the current page.”
When you use the Transfermethod or use cross-page posting totransfer processing from one ASP.NET page to another, the originating pagecontains request information that might be required for the destination page.You can use the PreviousPageproperty to access that information.

How use the Server.Transfer
Step 1:

We add the onepage as Default1.aspx and add one TextBox and Button and write this code onbutton click

protected voidButton1_Click(object sender, EventArgs e)



We access the textbox control data on this current page,we write the this code on page load

protected voidPage_Load(object sender, EventArgs e)
        TextBox txt = (TextBox)Page.PreviousPage.FindControl("TextBox1");
        Label1.Text =txt.Text;

So, we access the previous page data very fast as comparisonto response.redirect. so it one important method “to pass the data from one page to another”.Server.Transferacts as an efficient replacement for the Response.Redirect method.Response.Redirect specifies to the browser to request a different page. Becausea redirect forces a new page request, the browser makes two requests to the Webserver, so the Web server handles an extra request.


  Modified On Sep-18-2014 01:23:52 PM

Leave Comment