We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Async Method Calls in Form Validation

Thread ID:

Created:

Updated:

Platform:

Replies:

123301 Mar 5,2016 03:23 PM Mar 9,2016 07:59 AM WinRT 5
loading
Tags: SfTextBoxExt
Jürgen
Asked On March 5, 2016 03:23 PM

Hi.

I've been using SFTextBoxExt on my Windows Phone 8,1/RT app. I have also used validation with different types of criteria, and it looks pretty nice. Now I have a new criterion ("existing name in database") that requires me to do an asynchronous call to my database interface. What would be the best way to do this with SFTextBoxExt?

Best regareds,
-Juergen



Victory Jessie Selvam D [Syncfusion]
Replied On March 7, 2016 05:21 AM

Hi Juergen,

Thank you for using Syncfusion products.

We suggest you to use the properties PopupDelay and MinimumPrefixCharacters to force SfTextBoxExt control for waiting a few seconds before filtering suggestions. During this waiting time, asynchronous call to Database can be performed for filtering the autocomplete source. We have prepared a sample for the same and you can download it from the following link:

Sample: TextBoxExt

Regards,
Jessie

Jürgen
Replied On March 7, 2016 05:57 AM

Hi Jessie.

Thank your for your help and going through the effort of providing an example. My apologies for not being more specific in my original question but I'm not sure how to apply your example in my case.

Data validation is done using the properties Error and this and their respective "getters". If, for instance, the user now enters something in the name field of my form, I want to ask the database if that name is already taken. In case of a duplicate I want to give the user immediate feedback, same as with other invalid input. This request is not likely to take a lot of time. But making async calls from a "getter", even if possible, is probably not going to work well.

So my approach now would be to handle this outside SfTextBoxExt validation using the LostFocus event. That basically creates a second validation structure and feels a bit redundant. Is there another way?

Thanks and regards,
-Juergen

Victory Jessie Selvam D [Syncfusion]
Replied On March 8, 2016 07:58 AM

Hi Juergen,

Currently DataValidation can be performed in SfTextBoxExt control using the properties "Error" and their respective "this" getter. Making asynchronous Database calls in "Error" property getter will not yield expected result in validation, so we suggest you to perform validation in LostFocus event. We have prepared a sample for the same and you can download it form the following link:

Sample: TextBoxExt

Regards,
Jessie

Jürgen
Replied On March 8, 2016 03:10 PM

Hi.

Thanks once again for your efforts. Yes, something like this I had in mind. In the example you are actually testing for duplicates in both the LostFocus event and the this and Error getters.

It seems like setting the HasError property does not handle the formatting (red border) of the text box (triggered by returning non-empty string from this?).

Probably the best approach for my case is to fetch a list of existing names from the database upon page load and validate against that, which will likely also enable better performance for the validation.

-Juergen

Victory Jessie Selvam D [Syncfusion]
Replied On March 9, 2016 07:59 AM

Hi Juergen,

Error template will be refreshed in SfTextBoxExt control only during the validation process. The "this" getter which performs validation will be invoked only when the property value is updated in binding source. If control loses focus without any change in text, then validation will not happen and setting HasError property at this point is of no use. So we suggest your approach of fetching the list of existing names from database on page load and validating against that as best approach in this scenario.

Regards,
Jessie

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;