To continue with this content, please log in with your Data Access ID or create a new account.
Cancel Data Access ID
You may not be authorized to see this content. Please contact Data Access Europe for more information.
Cancel Data Access Europe
You are not authorized to see this content.
Cancel Data Access Europe
Next lesson:
Not validating user actions on the Server

5 Common WebApp Mistakes

Lesson 3: Using Get/Set insead of WebGet/WebSet

This is one we often see when developers transition from building Windows Applications to their first Web Application. In Windows, accessing properties is done using Get and storing properties is done using Set. Because the application is running locally and is a single process, this works as you’d expect it to.

In a Web environment however, this works a little different.

As we’ve discussed in the previous lesson, when building Web Applications you often have multiple processes on the server handling calls from the client. If you were to in one call store a property value using Set, and in the next call try to get that property using Get, chances are you will probably get a different value than you expected.

For the Web, we can make use of a specific kind of Properties called WebProperties. These come in various types, but the important thing to note is that their value gets stored either on the client or in a special table on the server. When accessing these WebProperties, it will try to get it from this table or the client based on the type of property. This ensures that the property value is always correct, regardless of what process is handling it.

To use WebProperties there are 2 specific commands to keep in mind:

  • WebGet is used to Get the value of a property
  • WebSet is used to store the value of a property

Does this mean you should avoid using Get and Set entirely in a Web Application? Not at all. In general, keep the following rules in mind:

  • You can use Get and Set during compile time, when your application is not yet running
  • You can use WebGet and WebSet during runtime, when you want to retrieve or change the value of properties when the application is running.
  • If all your logic is done in a single call, for example a button click, you can make smart use of Get and Set to temporarily store and access values between functions.

We have an entire course on Web Properties on the DataFlex Learning Center, which will go more into depth!