Validation of a property in Silverlight

Validation of a property in Silverlight

Old forum URL: forums.lhotka.net/forums/t/9342.aspx


CVARON14 posted on Sunday, August 08, 2010

Hello,   I'm working on my very first Silverlight application.    I have a quick question.  How do you validate a property in the client, when you need something from the server to validate?    An example will be, a user id validation, you need to make sure no one else is using the same user id entered.     I don't want to wait unit the user types all the information and clicks the save button,  I would like to have real-time validations.    Is there a way to do that, maybe through a command?

Thank you in advance.

RockfordLhotka replied on Monday, August 09, 2010

There are two parts to my answer.

First, yes you can do this. To do this, use an async rule and a command.

Second, remember that any rule of the type you describe is just your best guess at the time. You never really know if the rule will be violated until the user clicks save. This is because some other user might be doing the same exact thing, and might click save after you've check the value, but before your user has clicked save. So you still need to handle the case that failure occurs when the user clicks save.

Copyright (c) Marimer LLC