Difference between validate and causesvalidation 1

Source: Internet
Author: User

When designing the interface, we often encounter the need to verify some input to ensure the validity of user input.ProgramAs far as possible, the validation should be performed at the beginning, that is, the user enters the verification, then we use validate and causesvalidation.

So how can we differentiate between validate and causesvalidation?

1. Validate is an event and causesvalidation is an attribute.

2. Example

Private sub object_validate (keepfocus as Boolean)

Keepfocus: determines whether the control loses the focus value. When keepfocus is set to true, the control remains focused. validate event, this occurs before the focus is converted to another control. In this case, the causesvalidation attribute value of the other control is set to true (note: This is prerequisite , if the value of the causesvalidation attribute is set to false, the validate
event will not occur) . when a control loses its focus, the first event to be triggered is its validation event (similarly, the causesvalidation attribute of the control to be focused needs to be set to true, otherwise the validation will not be triggered ). With this feature, you can check the validity of data before the control loses focus.

The user control provides a validate event. It also provides a causesvalidation attribute through the extender object. When the focus is transferred from the user control to other controls whose causesvalidation attribute is set to trueCodeWill be executed. If you set the causesvalidation attribute of the user control to true, any validation event that passes focus to the control of the user control will be triggered. Otherwise, when causesvalidation
If the attribute is set to false, the validate event is not triggered!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.