Cross-page postbacks and back again retaining data from source page

后端 未结 1 1860
自闭症患者
自闭症患者 2020-12-12 03:37

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 so

相关标签:
1条回答
  • 2020-12-12 04:14

    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.

    0 讨论(0)
提交回复
热议问题