16.10. Adding Data to a Server-Side Shared Object
Problem
You want to add values to a server-side shared object.
Solution
Use the SharedObject.setProperty( ) method.
Discussion
If you try to add values to a server-side shared object in the same
way that you add values to a client-side shared object, you will
receive an error. The correct way to add values (or modify existing
values) to a server-side shared object is to use the
SharedObject.setProperty( ) method. The
setProperty( ) method requires that you specify
both the name of the property and the value to assign to the
property.
// This example code should appear in an.ascfile. It adds a property named //myPropertyto a shared object and assigns the property the value of 6. my_r_so.setProperty("myProperty", 6);
If you want to modify an existing property relative to its current
value, you can use the getProperty( ) method in
conjunction with setProperty( ):
// Set the myProperty property to one more than its current value.
my_r_so.setProperty("myProperty", my_r_so.getProperty("myProperty") + 1);See Also
See Recipe 16.9 for details on
SharedObject.getProperty( ). See Recipe 16.2 for important differences when setting
data for a local shared object.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access