ASPxClientComboBox.PerformCallback(parameter) Method
Sends a callback to the server.
Declaration
PerformCallback(
parameter: string
): void
Parameters
Name | Type | Description |
---|---|---|
parameter | string | Information for the Callback event. |
Remarks
Use the PerformCallback
method to update the control’s item collection. When you call this method, the ASPxComboBox clears its item collection and value on the client and then sends a callback to the server. On the callback, the server returns the required item collection and control selection.
Specify the PerformCallback
method’s parameter to manage the required data items on the server.
The PerformCallback
method’s callback raises the server-side Callback event, which gets the PerformCallback
‘s specified parameter as the event’s Parameter argument. This event allows you to process data items according to information obtained from the client.
The Callback event fires when you call the PerformCallback
method, and on every subsequent internal callback (for example, filtering or scrolling). Regardless of what causes a callback, the Callback event’s Parameter argument takes the value passed by the PerformCallback
method.
Note that you can change the control’s value and selection, but cannot change its structure on a callback initiated by the PerformCallback
method.
Implement Cascading Combo Boxes
Add two ASPxComboBox controls (CmbCountry and CmbCity) to your project and bind the CmbCountry combo box to the data source. The CmbCity combo box gets items on a callback according to the CmbCountry combo box value.
<dx:ASPxComboBox runat="server" ID="CmbCountry" DataSourceID="CountriesDataSource"... /> <dx:ASPxComboBox runat="server" ID="CmbCity"... />
Handle the client-side SelectedIndexChanged event. In this event handler, call the
PerformCallback
method with the CmbCountry combo box value as a parameter.function OnCountryChanged(cmbCountry) { cmbCity.PerformCallback(cmbCountry.GetValue().toString()); }
Handle the server-side Callback event raised by the
PerformCallback
method.In this event handler, call the
FillCityCombo
function that receives the event’s Parameter value as an argument (e.Parameter
).
This function selects items whose CountryName field is equal to the passed parameter value and binds the CmbCity combo box to these items.protected void CmbCity_Callback(object source, CallbackEventArgsBase e) { FillCityCombo(e.Parameter); } protected void FillCityCombo(string countryName) { if (string.IsNullOrEmpty(countryName)) return; using(var context = new WorldCitiesContext()) { var country = context.Countries.SingleOrDefault(c => c.CountryName == countryName); CmbCity.DataSource = context.Cities.Where(c => c.Country.CountryName == countryName) .OrderBy(c => c.CityName).ToList(); CmbCity.DataBind(); CmbCity.Value = country.City.CityName; } }