Presentation is loading. Please wait.

Presentation is loading. Please wait.

Validation Errors Mahender Senior Software Engineer

Similar presentations


Presentation on theme: "Validation Errors Mahender Senior Software Engineer"— Presentation transcript:

1 Validation Errors Mahender Senior Software Engineer
United Health Group

2 Mahender Sarangam Having 5 years of experience on .NET Technologies. Working as a Senior Software Engineer in United Health Group (UHG India Information Service Ltd.). Worked with Big Firms like Deloitte Consulting & Wipro Technology. Got Technical Acquaintance on Technologies like C#, ASP.NET,AJAX, LINQ, Silverlight, WPF,WCF ,SQL Server, Team Foundation Server(TFS) and SharePoint Technology. MCTS Certified in Web Technologies. Blog :

3 What are Validation Errors?
Silverlight provides several ways to validate data. The simplest and oldest approach is to use exception-based validation. In Silverlight 3 , Validation is performed using “ValidationOnException” property in Binding expression to throw validate errors . Incorrect data type: For example, a numeric property like UnitCost can’t accommodate letters or special characters. Similarly, it can’t hold extremely large numbers (numbers larger than E+308). Property setter exception: For example, a property like UnitCost may use a range check and throw an exception if you attempt to set a negative number. Read-only property: This can’t be set at all.

4

5 To enable the BindingValidationFailed event, you must set ValidatesOnExceptions to true (to detect errors) and NotifyOnValidationError to true (to fire the validation events). Whenever NotifyOnValidationError is true, BindingValidationError is fired and its bubble event,which can be handled in parent elements. For example : <TextBox Margin="5" Grid.Row="2" Grid.Column="1" x:Name="txtUnitCost” Text="{Binding UnitCost, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True}"></TextBox>

6 Steps for Data Object Validation
There are three basic steps to follow Implement the IDataErrorInfo or INotifyDataErrorInfo interface in your data object. Tell the data binding infrastructure to check the data object for errors and show error notifications. If you’re using the IDataErrorInfo interface, you set ValidatesOnDataErrors to true. If you’re using the INotifyDataErrorInfo interface, you set ValidatesOnNotifyDataErrors to true Optionally, set NotifyOnValidationError to true if you want to receive the BindingValidationFailed event. Optionally, set the ValidatesOnExceptions property to true if you want to catch other types of errors, such as data conversion problems. private <string, <string>> errors = new <string, List<string>>(); public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged;

7 Thank you


Download ppt "Validation Errors Mahender Senior Software Engineer"

Similar presentations


Ads by Google