开发者

Which page gets the postback with Server.Transfer?

开发者 https://www.devze.com 2022-12-19 23:21 出处:网络
I have a simple form that dynamically presents a data entry form, and the user does a postback and the results are saved to a database.I have created a new version of the form, and based on some infor

I have a simple form that dynamically presents a data entry form, and the user does a postback and the results are saved to a database. I have created a new version of the form, and based on some information on a database, when the user requests the URL of the old form, I wanted to do a Server.Transfer to the new *.aspx page to generate the page and handle 开发者_高级运维the postback. Since the URL of the page will not change, does that mean the postback gets sent to the original page? Would I then need to check if it's a postback, and if so then call Server.Transfer and allow the form data to be transfered to the new page?


It depends on what you mean by "gets" the postback. The first page will get the form values posted of course, since they are sent from the client. However, how far the first page gets through reacting to the postback information depends on when in the lifecycle you initiate the Server.Transfer. If it is extremely late in the lifecycle (like a click handler), then the first page will have pretty much gone through the entire postback process.

The optional parameter to preserve form values in Server.Transfer dictates whether the second page also reacts to the request as if it is a postback.


Take a look at the HTML source of the page after the Server.Transfer. If the form's action is the new ASPX then you are okay.

It would probably be easier to use a regular redirect. That way you don't have these kinds of issues.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号