ASP.NET 2.0 - Validation Groups and Cross-Page Posting

 1. Validation Groups

In ASP.NET 2.0, there is a new property called the ValidationGroup that can be assigned a string to specify a section. This property exists on the validation controls and on the controls that cause PostBacks to occur. When a control performs a PostBack, the validator controls that have a matching ValidationGroup property are validated.

On PostBack, the IsValid property on the Page object only reflects the validity of the validation
controls that have been validated. By default, these are the validation controls that are in the same ValidationGroup, but you can call a validation control’s Validate method to add that control to the set of controls that the IsValid reports on.

2. Cross-Page Posting

Cross-page posting is frequently desired in a scenario where data is collected on one Web page and processed on another Web page that displays the results. In this scenario,
a Button control has its PostBackUrl property set to the Web page to post back to. In the processing page, which is the Web page that you post back to, the data from the first Web page is available.

The processing page typically needs to access the data from the first page, which is possible by using the PreviousPage property of the Page object. The PreviousPage property
is set if you are cross-page posting, and if the PreviousPage is set to Nothing (C# null), no cross-page posting occurs.

You can access any of the controls in the previous page by using the FindControl method on the NamingContainer of the control that you are trying to locate.

Another way to access the previous page data is to create public properties that expose the data that you need to access. After creating public properties, you need to set the PreviousPageType directive on the result page.

你可能感兴趣的:(properties,validation,asp.net,processing,Access,PostBack)