Tag Archive: Asynchronous Data Validation


In my last blog post I had explained the two standard ways of  validating data in Silverlight 4. One way was implementing “INotifyProprtyChanged” interface. And the second way was “INotifyDataErrorInfo” interface, which is the new option available with Silverlight 4 for validating data.

Now in this blog post I will show, how we can use the validation asynchronously with “INotifyDataErrorInfo” interface in Silverlight 4.

Simple Scenario where Asynchronous Validation can be useful:

Assume that we are just registering new users for a website accepting username and password in Silverlight front-end UI. Now when user enters the preffered username, we need to check that preffered username is available or not. So we just call the web service for checking the availability of preffered username. But as we are using Asynchronous Data Validation to perform this username validation, and so while the web service returns the response, Silverlight front-end UI still remains available for User for entering password and so on……….

Here is the Entity class “User” which implements the “INotifyDataErrorInfo” interface as shown in the image below……

Here is the property “username” in the entity class “User” which is getting validated asynchronously…….

In this code “WebService.CheckUserNameAvailability(string userName, UserNameCallBack callBackMethod)” accepts userName as first parameter and CallBackMethod for UserNameCallBack delegate as a second parameter. So Web Service returns the response by calling this callBackDalegateMethod and passing “isUserNameAvailable” variable in the method. Then this method process the validation as shown in the image below………

So this callBackDalegateMethod will be called whenever the WebService will be ready with the response. So if web service returns the response in say 10 seconds, by the time, User can enter the password and so on.. And we can keep the “OK” button disable by that time as User can not click it before validation completes on “UserName” as shown in the image below…..

After this asynchronous validation, if UserName will not be available silverlight validation framework generates the error visualisation as shown in the image below……

 

So it was all about Asynchronous Data Validation with Silverlight 4.

For more info on silverlight, just go to, http://www.silverlight.net

For more on silverlight 4, click here, http://www.silverlight.net/getstarted/silverlight-4/

For more details on Silverlight 4.0, you can also browse through following blogs………

http://timheuer.com/blog/          —  Tim Heuer Blog – Silverlight Program Manager

http://blogs.silverlight.net/blogs/jesseliberty/       — Jesse Liberty Blog – Silverlight Program Manager

http://johnpapa.net/              —  John Papa website

http://adamkinney.wordpress.com/          — Adam Kinney Blog — For Silverlight graphics, interface and Expression Blend

Hi guys, if you are a Flash lover then it’s time to breakup now… because when you know the Silverlight 4.0 features in detail you will be definitely fall in love with Silverlight 4.0.

Silverlight 4.0

 Whether you are a flashy designer or developer who likes to design highly interactive games or websites or you are a high level Business Application Developer who needs great hold over the data, Silverlight 4.0 has the treat for both……

  • If you are a flashy website designer then you should get started exploring following new features in Silverlight 4.0 ……….

1.> Right Mouse Click Support

2.> Mouse Wheel Support

3.> Accessing Web Camera and Microphone

4.> Silverlight Controls as Drop Targets – Drag and Drop Support

5.> Hosting HTML Content – Now you can render HTML in Silverlight

6.> Local File Access – File from Local System can be accessed

7.> “RichtextArea” and “ViewBox” Controls

8.> Right to Left Language Support – For Languages like Hebrew and Urdu and lot more…

9.> Programmatically access to Global Clipboard

  • If you are a multitier Business Application Developer with complex architecture, you can start understanding Silverlight 4.0 with following new features……….

1. RIA Services support in Silverlight 4.0 with Visual Studio 2010

2. MEF for Application Extensibility – It’s Managed Extensibility Framework (MEF)

3. Network Authentication and Trusted Network Access

4. COM Object Access in Trusted Applications – Now you can access applications in Local System

5. Asynchronous Data Validations

6. DataGrid Enhancements in Silverlight 4.0

7. Printing APIs

8. Notification API

  • Some of these features are working with “Out Of Browser Applications” developed in Silverlight 4.0.
  • Currently only Silverlight 4.0 Developer Runtime is available.

I have already explored all these features and believe me, Silverlight 4.0 is simply rocking!!!

For more details on Silverlight 4.0 click any of the following links,

http://silverlight.net/getstarted/silverlight-4-beta/                   —  Official Microsoft Silverlight website

http://timheuer.com/blog/          —  Tim Heuer Blog – Silverlight Program Manager

http://blogs.silverlight.net/blogs/jesseliberty/       — Jesse Liberty Blog – Silverlight Program Manager

http://johnpapa.net/              —  John Papa website

http://adamkinney.wordpress.com/          — Adam Kinney Blog — For Silverlight graphics, interface and Expression Blend