Enterprise Library-validation Application Block learning Manual (Latest Version) Part 7

Source: Internet
Author: User
This article demonstrates how to use the Enterprise Library-validation Application Block verification management module and integrate the validation Application Block with Windows form. Verify the value of the control directly, instead of verifying the business object instance. This mechanism is different from the previous exercise. This article by the http://blog.entlib.com open source ASP. Net blog platform team according to the entlib Hol manual compilation to provide, welcome to exchange. Exercise 7: Validation Application Block And windows form IntegrationOpen the validationhol. sln project file under the \ Enterprise Library 4.1 Hol \ CS \ validation \ labs \ lab07 \ before directory. 1. Add validationprovider to open the mainform. CS file in the Visual Studio toolbar, right-click the file in the Visual Studio toolbar, and select choose items, as shown in.
In the displayed window, click the Browse button, navigate to the lib directory of entlib, and select the following Assembly: Microsoft. practices. enterpriselibrary. validation. integration. winforms. dll click the open button and select the assembly. In the following window, select the validationprovider check box, as shown in, and click OK. In this way, validationprovider will appear in tool box.
2. add an errorprovider in Windows form. Although this step is not required, the standard errorprovider control generally works with validatorprovider. If user data entry is invalid, feedback is provided. Expand the components tab in the toolbox toolbar, select errorprovider, and drag and drop it to the design interface. 3. add the validation support for the customer field. On the design page, select the validationprovider control and set the following properties in the Properties window: Name = customervalidationprovidersourcetypename = validationhol. businesslogic. customer, validationhol. shows businesslogicerrorprovider = errorprovider1.
(2) set the validation attributes of the firstname and lastname text boxes. Select the firstname text box and set the following attributes: Performs validation on customervalidationprovider = truesourcepropertyname = firstname
Repeat the preceding operation and select the lastname text box and set the following attributes: Performs validation on customervalidationprovider = truesourcepropertyname = lastname select SSN text box and set the following attributes: Performs validation on customervalidationprovider = truesource. add the validation support for the address field (1) drag the validationprovider control again to the design interface; (2) set the following attributes of the validationprovider: Name = addressvalidationprovidersourcepropertyname = validationhol. businesslogic. address, validationhol. businesslogicerrorprovider = errorprovider1
Set the attributes of the street address, city, and zip code text boxes, as shown in the following code: Invalid mvalidation on addressvalidationprovider = truesourcepropertyname on addressvalidationprovider = streetaddress city text box: required mvalidation on addressvalidationprovider = truesourcepropertyname on addressvalidationprovider = city zip code text box: Required mvalidation on addressvalidationprovider = truesourcepropertyname on addressvalidationprovider = zipcode State drop-down list box: Invalid mvalidation on addressvalidationprovider = truesourcepropertyname on addressvalidationprovider = state 5. Run the sample program and check the Running Effect of validation, as shown in. Http://www.entlib.com professional ASP. NET e-commerce platform team, welcome to continue to visit the validation Application Block learning manual. Reference:Validation Application Block hands-on labs for Enterprise Library

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.