跨页回发,并从源页面再次保存数据 [英] Cross-page postbacks and back again retaining data from source page

查看:88
本文介绍了跨页回发,并从源页面再次保存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时有可能使用跨页回发(或类似的方法,也许Server.Transfer的)发布表单数据(例如,数据集A)的网页,然后允许用户添加一些额外的信息(比方说,数据集B),然后回发到原始页面的完整的数据集(A + B),然后流经正常事件的执行过程中,类似仿佛+ B在原始页面上提交的所有数据本身在一个正常的回发?

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.

例如:

1可以有各种文字输入的形式,和两个隐藏字段Hidden1 + Hidden2这是空的。

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

在第1页上的表单提交用户使用2页psented $ P $,他们完成该页面,然后从第1页中的所有表单数据发回到页面1,但隐藏字段1 + 2完成。第1页则拥有所有需要完成的信息。

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.

我在想,也许2页只需用previousPage,并采取了POST数据,添加到它,然后张贴回到第1页,但如果从第1页来了,没有第2页。但我不知道这是可能的,ASP.NET可能会读这是篡改数据?

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?

这是类似于这个问题,但在这个例子每一页specfic到previous页。

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

推荐答案

您首先创建一个让您的信息的类和它打算从页面移动到页面并填写数据。

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

在每个页面你有这个类,一个变量的引用,那醚创建一个新的醚从previous页面得到它。你把它存储在ViewState中

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

现在从第1页 - >第2页

Now from Page1 -> Page2.

您从第1页由一组发送到

You send it from Page1 by set to the

PostBackUrl="Page2.aspx"

在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;
    }
}

和另外一个手工的方式是让你的类seriable,通过邮寄把它作为XML和德code那么它的下一个页面上。

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

这篇关于跨页回发,并从源页面再次保存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆