$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
ComboBox Client Side Event in ASP.NET
Home > How to > ComboBox Client Event
Similar to other controls from the UI SDK for ASP.NET AJAX, this ComboBox Control also offers several client-side events for developers to detect and respond to the specific actions that the end-users have performed with the combobox. And in this online tutorial, we will offer you detailed programming guidance on how to call these combobox client-side events in aspx web page.

Available ComboBox Client-side Events

Here we list the client-side events that are supported by the asp.net ComboBox control. And you can use these client-side events to design the behavior of the combobox using ASP.NET AJAX.
  • onDropDownOpening: this event will be raised when the combobox drop-down list is about to open.
  • onDropDownOpened: this event will be raised when the combobox drop-down list has been opened.
  • onDropDownClosing: this event occurs when the combobox drop-down list is about to close.
  • onDropDownClosed: this event occurs when the combobox drop-down list has been close. And this event can be counted as a subsequent result of the onDropDownClosing event.
  • onSelectedIndexChanging: this event is raised when the selected item is about to change for responding to the action of end user.
  • onSelectedIndexChanged: this event is raised when the selected item has been changed for responding to the action of end user.
  • onItemsRequesting: this event is raised when the load-on-demand mechanism is triggered by end users with the action to type in the input area or open the combobox drop-down list.
  • onItemsRequested: this event is triggered once the load-on-demand mechanism has loaded new items to the asp.net Combobox Control.
  • onKeyPressing: this event is called when the web ComboBox item is selected and the user presses a key.
  • onTextChange: this event occurs when the text string in the combobox input area has been changed.
  • onItemChecking: this event is triggered when a certain item is about to be checked.
  • onItemChecked: this event is triggered when a certain item has been checked.
  • OnItemsRequestFailed: this event occurs when the load-on-demand callback reports error.
  • OnBlur: this event occurs occurs when asp.net ComboBox loses focus.
  • OnFocus: this event occurs occurs when web ComboBox gets input focus.
  • OnLoad: this event is called occurs when the ComboBox has been fully initialized on the client-side.
  • OnItemDataBound: this event occurs for each item that is created during Web Service Load on Demand.
  • OnTemplateDataBound: this event is raised when the client template is bound.
  • OnCheckAllChecking: this event is called when the all items check box is about to be checked.
  • OnCheckAllChecked: this event is called when the all items check box has been checked.

How to Call ComboBox Client-side Events

If you want to use above combobox client-side events, you just need to write a javascript function that can be called when the event is triggered. After that, you can define the name of the javascript function as the value of the corresponding asp.net ComboBox property. Here we attach an example to show you how to use these combobox client-side events APIs in aspx web page. If you meet any problems in the testing process of above client side events, please feel free to contact us.
<script type="text/javascript">
function logEvent(eventInfo) {
var EventLogConsole = $get("<%=EventLogConsole1.ClientID%>");
EventLogConsole.innerHTML += eventInfo + "<br/>";
}
function onDropDownOpening(sender) {
logEvent("Drop Down opening");
}

function onDropDownOpened(sender) {
logEvent("Drop Down opened");
}

function onDropDownClosing(sender) {
logEvent("Drop Down closing");
}

function onDropDownClosed(sender) {
logEvent("Drop Down closed");
}

function onSelectedIndexChanging(sender, eventArgs) {
var selectedItem = sender.get_selectedItem();
var previouslySelectedItemText = selectedItem != null ? selectedItem.get_text() : sender.get_text();

logEvent("Index changing from Item '" + previouslySelectedItemText + "'");
}

function onSelectedIndexChanged(sender, eventArgs) {
var selectedItem = eventArgs.get_item();
var selectedItemText = selectedItem != null ? selectedItem.get_text() : sender.get_text();

logEvent("Index changed to Item '" + selectedItemText + "'");
}

function onItemsRequesting(sender, eventArgs) {
logEvent("Requesting Items with text '" + eventArgs.get_text() + "'");
}

function onItemsRequested(sender, eventArgs) {
logEvent("Requested items with text '" + eventArgs.get_text() + "'");
}

function onKeyPressing(sender, eventArgs) {
logEvent("Pressing key code: " + eventArgs.get_domEvent().keyCode);
}

function onTextChange(sender) {
logEvent("Text changed to: " + sender.get_text());
}

function onItemChecking(sender, args) {
var checked = args.get_item().get_checked();
if (!checked)
logEvent("Item '" + args.get_item().get_text() + "' checking");
else
logEvent("Item '" + args.get_item().get_text() + "' unchecking");
}

function onItemChecked(sender, args) {
var checked = args.get_item().get_checked();
if (checked)
logEvent("Item '" + args.get_item().get_text() + "' checked");
else
logEvent("Item '" + args.get_item().get_text() + "' unchecked");
}
</script>
ASP.NET AJAX UI Controls