Skip to main content
Tab

ListBoxProperties.EnableSynchronization Property

Gets or sets whether to update the Items collection on the server once you add or remove an item on the client.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.2.dll

Declaration

[DefaultValue(DefaultBoolean.Default)]
public DefaultBoolean EnableSynchronization { get; set; }

Property Value

Type Default Description
DefaultBoolean Default

One of the enumeration values.

Available values:

Name Description Return Value
True

The value is true.

0

False

The value is false.

1

Default

The value is specified by a global option or a higher-level object.

2

Remarks

Note

The ListBoxExtension‘s EnableSynchronization property has no effect.

You can enable client-side API members of the list box editor to add and remove list items on the client. Due to security reasons, the editor does not update its server-side Items collection in response to client-side item modifications. Refer to the following topic for more information: Validation in List Editors.

Follow the steps below to enable item synchronization in the list box editor:

  1. Make sure that the DataSecurityMode property is set to Default.
  2. Make sure that the EnableCallbackMode property is set to False (the default value).
  3. Set the EnableSynchronization property to True.

When the EnableSynchronization property is set to Default, the ListEditEnableSynchronizationDefaultValue setting specifies whether item synchronization is enabled.

The following example enables item synchronization for the list box editor:

<dx:ASPxListBox ID="ASPxListBox1" runat="server" EnableSynchronization="True">
    <Items>
        <dx:ListEditItem Text="Item 1" Value="Item 1" />
        <dx:ListEditItem Text="Item 2" Value="Item 2" />
        <dx:ListEditItem Text="Item 3" Value="Item 3" />
    </Items>
</dx:ASPxListBox>

Item Synchronization Specifics

Item synchronization has the following specifics:

  • Synchronization does not affect the bound data source. Update the data source manually to prevent data loss.
  • You should populate the list box editor with items before the editor synchronizes item collections for the first time. To do this, specify the Items collection in markup or add items during editor or page initialization (Init or Page_Init events).
  • ItemInserting and ItemDeleting events allow you to cancel item insert and delete operations. Handle ItemInserted and ItemDeleted events to respond to item collection modifications.

Important

When item synchronization is enabled, make sure that the editor encodes its property values. Otherwise, your application may be vulnerable to cross-site scripting (XSS) attacks. Refer to the following topic for more information: HTML Encoding.

See Also