Why not to use cross page post back when validation the page.
Hi

In ASP.Net 2.0 we can use the cross page post back to post to a different page. We can also get the same effect by using the Server.Transfer method. You can look at this post of mine to see how to work around with cross page post back.

But we cannot use cross page post back at every situation. There are some disadvantages of using cross page post back at some situation especially validation.

If we have disabled the client side validation for our controls then the page will post back without any validation. Even if the validation is not turned off, we can’t always use validation on the client (some custom validation controls will only be able to validate servers-side), nor can we always trust the client to perform validation.

Server side validation presents a problem for cross page post backs because our response will come from the destination web form instead of the original web form where the user failed validation. When we inspect the PreviousPage.IsValid property in the destination page validation control will run server side, in case of a cross page post back. When we touch the PreviousPage property the runtime loads and executes the PreviousPage form, including the validation controls.

If we pass the validation then there is no problem but what happens when the user fails the validation. There is no way to load the original page with all the input controls with there value and showing the user the reason for the failure of the validation. This scenario will not be a problem with Server.Transfer because if the validation fails we can show the error message to the user on the page otherwise transfer him to a new page.

Hope this helps
Thanks
Vikram

Share this post   Email it |  digg it! |  reddit! |  bookmark it!

Feedback

Please post your comments:

Name:  
Email (optional): Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks  
Enter the text you see in the box:
 
Copyright © 2006 - 2008 Vikram Lakhotia