Back to Devexpress

ASPxListBox.Callback Event

aspnet-devexpress-dot-web-dot-aspxlistbox-c6082089.md

latest5.3 KB
Original Source

ASPxListBox.Callback Event

Fires when a round trip to the server has been initiated by a call to the client ASPxClientListBox.PerformCallback method.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public event CallbackEventHandlerBase Callback
vb
Public Event Callback As CallbackEventHandlerBase

Event Data

The Callback event's data class is CallbackEventArgsBase. The following properties provide information specific to this event:

PropertyDescription
ParameterGets a string that contains specific information (if any) passed from the client side.

Remarks

The Callback event allows any desired server-side processing to be performed in response to a call to the client PerformCallback(parameter) method, and the editor’s content being updated, as required.

Specific information passed from the client side can be obtained via the Parameter property.

Note that the necessary actions can be additionally performed on the client side before and after callback processing by using the BeginCallback and EndCallback client event.

Note

The ASPxListBox control allows you to modify the Items collection on callbacks only (e.g. add and remove items, populate the controls with new data from a data source, etc.).

It is not possible, for example, to modify a column collection, change items selection, or change SelectionMode on callbacks. To perform these actions on the client side, you can wrap the control with the ASPxCallbackPanel control and process a required scenario on a callback to the panel.

After the PerformCallback method is called on the client, the Callback event handler is raised during each page postback. You can use the IsCallback property to determine if the PerformCallback method raises the event.

csharp
protected void ASPxListBoxInstance_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e) {  
    DevExpress.Web.ASPxEditors.ASPxListBox cmb = (DevExpress.Web.ASPxEditors.ASPxListBox)sender;  
    if(cmb.IsCallback) {  
        //Raised by PerformCallback  
    }  
    //else //Raised by Postback  
}
vb
Protected Sub ASPxListBoxInstance_Callback(ByVal sender As Object, ByVal e As DevExpress.Web.CallbackEventArgsBase)  
    Dim cmb As DevExpress.Web.ASPxEditors.ASPxListBox = CType(sender, DevExpress.Web.ASPxEditors.ASPxListBox)  
    If cmb.IsCallback Then  
        'Raised by PerformCallback  
    End If  
    'Else 'Raised by Postback  
End Sub

Example

This part of the Multiple Selection demo illustrates how to use multi-selection mode for the ASPxListBox editor.

aspx
<dx:ASPxListBox ID="lbFeatures" runat="server" SelectionMode="CheckColumn" Height="210px"
    DataSourceID="Features" ValueField="ID" ValueType="System.String" TextField="Name">
    <ClientSideEvents SelectedIndexChanged="function(s, e) {lbModels.PerformCallback('1');}" />
</dx:ASPxListBox>
<dx:ASPxListBox ID="lbModels" runat="server" SelectionMode="CheckColumn" 
Height="210px" width="250px" ClientInstanceName="lbModels" 
DataSourceID="PhoneModels" ValueField="ID" ValueType="System.String" 
OnCallback="lbModels_Callback" >
   <Columns>
      <dx:ListBoxColumn FieldName="Name" Caption="Model" width="100%"/>
      <dx:ListBoxColumn FieldName="Price" width="50px"/>
   </Columns>
</dx:ASPxListBox>
csharp
protected void lbModels_Callback(object sender, DevExpress.Web.CallbackEventArgsBase e) {
    FilterModels(lbFeatures.Items);
    lbModels.DataBind();
}
protected void FilterModels(ListEditItemCollection items) {
...     
}
...
vb
Protected Sub lbModels_Callback(ByVal sender As Object, ByVal e As DevExpress.Web.CallbackEventArgsBase)
    FilterModels(lbFeatures.Items)
    lbModels.DataBind()
End Sub

Protected Sub FilterModels(ByVal items As ListEditItemCollection)
' ...
End Sub

See Also

PerformCallback(parameter)

BeginCallback

EndCallback

List Box

ASPxListBox Class

ASPxListBox Members

DevExpress.Web Namespace