We can remove the @ Previous Page directive from the second form and use the following code instead.It requires a little more code to dig the parameter out, but we have decoupled the forms and gained some flexibility. The most serious is that the URL in the browser does not change.Notice we have an Is Cross Page Post Back property we can evaluate to determine if the request arrived as a result of cross page post back.
We do not need to respond to the Click Event for this button.The hard question to answer is what do we do when the user failed the validation tests?There is no easy way to get them back to the original web form, with their input in tact, and with an explanation about why their validation tests failed (remember, validation isn’t working on the client in this case). Transfer this scenario was not a problem, as we could skip the Transfer when validation failed and let the validation controls display error messages to the user from the original web form. NET we’ve become accustomed to web forms posting back only to themselves. Imagine a web form requiring a user to enter a parameter into a Text Box control. One way to get this parameter to a second form would be the Response. We could add a button to the form with the following event handler. Redirect needing a round trip to the client, but it is a simple approach.Since this behavior tends to create big balls of mud, we’ve looked for ways to push data between forms. However, the length of the query string is limited, and we may not want the parameter displaying in the destination’s URL. NET 2.0 compilation model, but like a blind man with an elephant I hadn’t quite felt the full elephant. The code for the sender might look like the following.
Any number of pages can transfer into this destination page. The browser still believes it has posted back and received content for the first web form, so history and book-marking suffer.