Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Implementing Two-Way Control Binding for Web Forms : Page 6

ASP.NET's native data binding provides only one-way data binding. With a little bit of effort, it's possible to extend the native functionality and provide flexible two-way data binding and a few other simple enhancements that drastically reduce the amount of code you have to write for binding data to controls.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Error Display
This next method creates an array of BindingErrorobjects containing information about the error. You can configure custom binding error messages by setting a binding error message on the control (see Figure 4). Otherwise, the code in Listing 7 assigns a generic error message to the property.

Reflection makes it possible to dynamically read and assign property values that were assigned at design time. You can think of it as a simple evaluation mechanism.
This array of binding errors, if any, is returned from the Unbind operation. A couple of helper methods exist to turn the array into HTML. The code for the Inventory example you saw earlier looks something like this:

... BindingError[] Errors = wwWebDataHelper.FormUnbindData(this); if (Errors != null) { this.ShowErrorMessage( wwWebDataHelper.BindingErrorsToHtml(Errors) ); return; } if (!Inventory.Save()) ...

In addition, each of the controls contains some custom code to display error information, as shown in Figure 5.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date