3. Properties

One important aspect of a widget property is that it is read-only in WEMscript. To assign a new value to a property, you need to perform a postback. Let's look at some example code, assuming we have created a literal text widget property called @Name.

/* Reading the value from the property is fine */
var @uppercasedName = ToUpper(@Name)

/* However, assigning a new value will throw an error */
@Name := "Jane Doe"

To assign a new value to the property, you need an HTML form. After a WEM event, the property is set to its new value if it has been correctly validated. Here is a short example of how this looks:

<? register input @Name ?>
<input type="text" name="<?attr OutputId(@Name) ?>" value="<?attr @Name ?>">

In the next chapters, we will provide a more in-depth explanation of what the statement register input and the function OutputId() do.

Last updated

Was this helpful?