To better understand the difference between server and browser events, we have prepared a simple example:
On the home page, click "Tutorial", then in "Tutorial - WEBDEV overview", click "Open exercise project".If UAC is enabled, a specific window may appear. This window indicates that the WD300Admin.exe program will be run on the current computer. Grant the authorization. This program corresponds to the local WEBDEV administrator that is used to test websites developed with WEBDEV. Its features will be presented later in this tutorial.
Open the "PAGE_Product_form" page in the editor: In the "Project explorer" pane, expand "Pages" then "Administration_pages". Double-click "PAGE_Product_form". The page is displayed in the editor.
This page is a form used to create and edit products. Scroll down the page.
This page contains Edit controls and an "OK" button at the bottom.
The "OK" Button control must do two things:
Check that all required fields have been filled. Save the values from the controls to the database. These actions are executed in the code of the button.
Code of the "OK" button :
Select the "OK" button. Blue handles appear around the control. Press F2 to open the code editor. The WLanguage events of the Button control are displayed with the associated code.
Let's see the WLanguage code displayed :
The Button control has three events: Initialization, click on the browser side and click on the server side. The different types of code are identified using colors:The browser code, that will be executed on the end user computer, has a green header. The server code, which will be executed on the server, has a yellow header. In our example, all input checks are performed in browser code (green header). For example, the EDT_Reference control must not be empty. The corresponding code is as follows:
Click on BTN_OK (onclick browser event)
IF EDT_Reference ~ = "" THEN
Error ( "Enter a reference." )
SetFocusAndReturnToUserInput ( EDT_Reference )
END
This check is performed in browser code because there is no need to go back to the server to check that the controls are filled.
This avoids unnecessary server requests, reduces waiting times and improves website navigation.
Once the browser code has been run, the page sends the values entered to the server. Then, the server runs the server code. In the server code, you have the ability to process the information received.
In our example, the information received is added to the database via the following code:
PageToFile ( )
IF ImagePath < > "" THEN
Product . Visual = fLoadBuffer ( ImagePath )
END
IF Product . . NewRecord THEN
Product . Add ( )
ELSE
Product . Modify ( )
END
PAGE_List_of_products . Display ( )
This operation cannot be performed in browser code because the database is common to all website users and is located on the server.