How to handle cross-page posting problem?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, friends,

I tried to do cross-page posting, i.e., in firstpage.aspx I used
action="secondpage.aspx".

Since I am using asp.net 1.1, so it always goes back to firstpage.aspx
aftern submitting firstpage.aspx.

I then tried in page_load of firstpage.aspx:

if (this.IsPostBack)
{
Server.Transfer("secondpage.aspx");
}

It did go to secondpage.aspx, but all submitted info were lost and could not
be seen in secondpage.aspx.

Any sample source code, reference papers? Help please...
 
when you transfer, you can access the previous page (Context.Handler).
expose the fields you need to access as global properties, then you can
access them, after you cast hander as the page type.

-- bruce (sqlwork.com)
 
Hi Andrew,
In asp.net 1.1, we can do cross posting by omitting the runat="server"
attribute in the form tag.But the drawback here is uve to use HTML controls
instead of server controls..
See the below article for more info
http://www.c-sharpcorner.com/Code/2005/March/PostingData.asp

If u want to use server controls ,then u can persist values in another page
by using session,querystring.
 
Hi,

I would not do the transfer/redirect in Page_Load method, by checking
IsPostBack.
Good practice is using the corresponding event handler methods for the
same. For example, if you have a button, named SaveButton, there would
be a event handler, namely SaveButton_Click(). In this method, use the
HttpContext properties/methods to save the values posted back by the
form. Then do the Server.Transfer(). The other page would be able to
retrieve the values using HttpContect properties/methods.

Cheers!
Rajeev Gopal
http://www.geekswithblogs.net/rajeevgopal
 
Back
Top