views:

41

answers:

1

Is it possible to use cross-page postbacks (or a similar method, perhaps Server.Transfer) to post form data (say, Data-set A) to a page, which then allows the user to add some additional information (say, Data-set B) and then postback to the original page the complete set of data (A+B) which then flows through the normal event execution process, similar to as if all data A+B was submitted on the original page to itself in a normal postback?

I don't want the second page to have any type knowledge of the original page, it just needs to supply two additional feeds and send the data on. This way different pages and controls could use this method for gaining additional data.

For example:

Page 1 could have a form with various text inputs, and two hidden fields Hidden1 + Hidden2 which are empty.

When the form on page 1 is submitted the user is presented with page 2, they complete that page and then all the form data from page 1 is posted back to page 1 but with the hidden fields 1 + 2 complete. Page 1 then has all the information it needs to complete.

I'm thinking that perhaps page 2 just needs to use PreviousPage and take its post data, add to it and then post it back to page 1, but as if it came from Page 1 and not Page 2. But I'm not sure if this is possible and ASP.NET might read this as tampered data?

This is similar to this 'question', but in that example each page is specfic to the previous page.

Happy to reword this if I'm not particularly clear...

A: 

You first create a class that keep your information and its going to move from page to page and fill with data.

In every page you have a reference to this class, a variable, that ether create a new ether get it from the previous page. You store it on ViewState

Now from Page1 -> Page2.

You send it from Page1 by set to the

PostBackUrl="Page2.aspx"

On page2.aspx you set where you can get informations

<%@ PreviousPageType VirtualPath="~/Page1.aspx" %>

and you get them by...

if (Page.PreviousPage != null)
{
    if(Page.PreviousPage.IsCrossPagePostBack == true)
    {
        GetTheClass = PreviousPage.MyDataClass;
    }
}

And one other manual way is to make your class seriable, send it as xml via post, and decode it on the next page.

Aristos
Hm, I wonder if this could work if an abstract class holds the two fields that would be populated by page 2, so that page 2 doesn't need to know about the other fields, it can just fill those in and pass it on. I don't want Page 2 to know about Page 1 though, instead of specifying the virtual path perhaps it could just cast PreviousPage to a specific type of Page that has a public property of the type of that abstract class? (And any pages that implement this method would need to be of that type of page)
PirateKitten
@PirateKitten then just send them as xml, or your simple string struct, from one to the other.
Aristos