How to handle cross-page posting problem?

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...
 
B

Bruce Barker

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)
 
G

Guest

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.
 
R

Rajeev Gopal

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top