Apply validation on specific button pressApply validation on specific button press
Old forum URL: forums.lhotka.net/forums/t/2048.aspx
GrullonM posted on Friday, December 29, 2006
I am working on an application that has two submit buttons.
- One is a SAVE button
- The second on is a SUBMIT button
The save button only requires an email field to be filled. The purpose of this button is to allow end users to start filling out the form and if they want to finish later, they can hit the SAVE button and the info will be saved in the database.
The SUBMIT buton on the other hand, makes sure that 90% of the values on the form are filled out.
I guess the question is how can I call the validation rules only when the SUBMIT button has been pressed? Do I create a separate Sub Procedure for this button, or maybe a second object? How about custome rules?
Thanks,
Miguel
Brian Criswell replied on Friday, December 29, 2006
Is this a Windows or web application?
GrullonM replied on Friday, December 29, 2006
Sorry... it is a web application!Brian Criswell replied on Saturday, December 30, 2006
I would suggest adding an additional property called AllowSave. When this property is set to true, ValidationRules.CheckRules is called and the validation rules detect this and return true regardless of whether the corresponding properties are set. Only Email would ignore AllowSave as it is required even when you are saving. Inside your DataPortal_xyz methods, you set _allowSave back to false. You then have two scenarios:
- Save is clicked: AllowSave is set to true and the object is saved if it has a valid email address.
- Submit is clicked: The validation is already running as normal so just return any problems with the validation.
DansDreams replied on Saturday, December 30, 2006
I thought I read that the latest CSLA had a new feature of two levels of broken rules. Save would be allowed if there were no errors, while Submit would have a more strict requirement of no warnings either.
Or am I confused with the DevExpress error provider control which has multiple levels? After yesterday my head is spinning.
Copyright (c) Marimer LLC