Monday, 25 August 2008

ASP.NET Silverlight (A Vision - Part 2 - Validators)

So in my last article, I outlined my vision (own personal opinion, not any inside knowledge) of where I think ASP.NET might be heading.

In this article I discuss how existing controls (validators in particular) could be modified to support Silverlight.

ASP.NET Existing Validators

ASP.NET at the moment has a bunch of standard validators

  • RequiredFieldValidator
  • CompareValidator
  • RegularExpressionValidator
  • CustomValidator
  • etc.

All these validators support the ability to validate both server side and clientside.  If clientside validation is selected some javascript will be injected onto your page to perform the validation.

Silverlight Validation

In the future I can see this being extended to support Silverlight validation.  If the validator is configured to support Silverlight Validation and ASP.NET detects your browser supports Silverlight then it will use Silverlight rather than Javascript to perform client side validation.  If your browser doesn't support Silverlight it could revert back to Javascript.

This would be especially cool with the Validation Summary control which doesn't really work well in ASP.NET as is.

The controls could also support templating so you could use your own XAML for the validation.

Custom Validation

The power of a Silverlight custom validator would be immense, you could write a C# validation routine and have that perform client side.  This would bring much more power to validation rather than doing simple regular expressions, or complex Javascript.

For example you could right a client side custom validator which performs a dictionary check against a dictionary web service.


This would mean that you could start to setup your existing websites to use the power of Silverlight without necessarily building an entire website in Silverlight.  This would also be a very cool addition to the capabilities of the ASP.NET Framework.

In my next article I will discuss where else this sort of technique could go.

No comments: