Friday, March 16, 2007
Validating inputs using Validation Application Block and XmlHttpRequest (Part II): The code!
Someone has left me a comment in my previous post about this topic asking for the code to take a look at the solution. So I think that instead of making you waiting for a detailed explanation of the solution you could take a look at it and see if it's useful for some specific scenarios you may be interested:
There is the code. The zip file contains the Proxy implementation, the JS function and the TypeDescriptor infrastructure you need to make the VAB get the html control value.
Of course this is draft code, and it's only for demo purposes. I hope you enjoy it and provide some feedback!
An example of how to use the Client Validation could be:
<asp:TextBox ID="TextBox1" runat="server" />
<cc2:ClientPropertyProxyValidator
ID="ClientPropertyProxyValidator1" runat="server"
ControlToValidate="lastNameTextBox" PropertyName="LastName"
RulesetName="RuleSetA"
SourceTypeName="ValidationQuickStart.BusinessEntities.Customer" />
The example was taken from the Validation Quickstarts and you can realize that you only have to change the control declaration!! (PropertyProxyValidator -> ClientPropertyProxyValidator)