|
ASP.NET Validation Package Demo 6 - Mixed client-side and server-side only valdationThe following demo contains a login form contained within a user control. It contains the following series of validation rules:
Obviously the username and password cannot be verified on the client. Enter a username and password that is different to the fixed username and password above and it'll appear as though the for has accepted it. Submit the form, however, and you'll see that the login has failed. Open up the code window for the login control and you'll see how this is achieved by subclassing the ValidatorEntryServerOnly class. The first thing you'll notice is that the subclassed validation entry (ValidatorEntryLogin) has been created within the namespace of the login user control itself (i.e. it's within the user control's script block). Clearly this is not common practice and in reality, the ValidatorEntryLogin class would be considered a "business object" since the RunValidation method would, in a normal situation, be performing a back-end database function checking a user's credentials. I've placed this class within the namespace of the user control for the simple reason that I wanted to give it syntax highlighting - since the syntax highlighter I wrote for these demo pages has been designed to work with ASPX and ASCX pages only. One other thing you'll notice about the ValidatorEntryLogin class is that it is overriding the "FirstObject" property. This is required when validation groups are used. More detail about this type of subclassing is provided in the ASP.NET Validation Package documentation. Note that the validation summary control used in this demo is the same one used in the "Customised validation summary" demo. >> Show me the code for the login form control! >> Turn off client side validation! © 2002 - 2008 Copyright, Disclaimer and Privacy Statement |
||||||