Tuto WEBDEV 25

Part 3: Intranet site with data 119 The "VALIDATE" Button control will be used to: • check the data typed: this check consists in verifying that the different page controls have been filled by the user. This check does not require any access to the server and it can be performed in browser code. • save the data typed in the Product data file. It is saved in server code. The data is sent to the server then it is saved in the data file. ▶ Write the code associated with the "Validate" button: 1. Select the "VALIDATE" Button control and press F2. The events associated with the Button control are displayed. 2.  In the "Click (browser)" event of the Button control, write the following code for checking the data entered: IF EDT_Reference ~= "" THEN Error("A reference must be typed.") ReturnToCapture(EDT_Reference) END IF EDT_Caption ~= "" THEN Error("A caption must be typed.") ReturnToCapture(EDT_Caption) END IF EDT_Description ~= "" THEN Error("A description must be typed.") ReturnToCapture(EDT_Description) END IF EDT_PriceBT = 0 THEN Error("A price must be typed.") ReturnToCapture(EDT_PriceBT) END 3.  Let’s take a look at this WLanguage code: • For each edit control found in our page, a check is performed to find out whether a value was typed. • The ‘~=’ operator is used to check the equality, excluding the case and the punctuation. • If no value is typed, an error message asks the Web user to perform an input ( Error ). The code execution is stopped and the input is forced in the relevant edit control by ReturnToCapture . 4.  In the "Click (server)" event of the Button control, write the WLanguage code for saving the data: PageToFile() HModify(Product) PageDisplay(PAGE_List_of_products)

RkJQdWJsaXNoZXIy NDQ0OA==