Skip to main content

ASPxClientComboBox.GetSelectedItem Method

Returns the combo box editor’s selected item.

Declaration

GetSelectedItem(): ASPxClientListEditItem

Returns

Type Description
ASPxClientListEditItem

An ASPxClientListEditItem object that represents the selected item.

Remarks

Use the GetSelectedItem method to obtain the selected item within the editor’s dropdown list. A null value indicates that no item is currently selected within the editor.

Example

This example demonstrates how to show the current item image within the ASPxComboBox text. To accomplish this task, handle the client-side ASPxClientComboBox.SelectedIndexChanged event, and change the background image of the control’s main HTML element. Also, you should set the ASPxComboBox.BackgroundImage.ImageUrl on the server side to synchronize the selected image. It is necessary to manually adjust the paddings and control height.

function SetComboBoxImage(s){
    var cbstyle = s.mainElement.style;
    cbstyle.backgroundImage = 'url('+(s.GetSelectedItem().imageUrl)+')';
    cbstyle.backgroundRepeat = "no-repeat";    
    cbstyle.backgroundPosition = "2px";
}
See Also