New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

Setting Event Handlers via JavaScript

RadRadioButtonList API exposes client-side methods to attach and detach functions to its event. They can be used as an alternative to the server-side properties for handling events.

To handle the desired event, you can use the respective add_<eventName>(handlerFunction) to attach the desired handler (i.e., add_itemClicked for the itemClicked event), where the parameter handlerFunction should be of type function. To remove the handler that has been added previously, the respective remove_<eventName>(handlerFunction) should be used.

The next three examples show how to add and remove handlers on the client:

Example 1: Adding a named (non-anonymous) JavaScript click handler to RadRadioButtonList.

JavaScript
function Click(sender, args){
	alert("RadRadioButtonList's item was clicked");
}

function addHandler(){
	var radioButtonList = $find("<%=RadRadioButtonList1.ClientID %>");
	radioButtonList.add_itemClicked(Click);
}

Example 2: Adding an anonymous JavaScript click handler to RadRadioButtonList.

JavaScript
function addHandler(){
	var radioButtonList = $find("<%=RadRadioButtonList1.ClientID %>");
	radioButtonList.add_itemClicked(function (sender, args) { alert("RadRadioButtonList's item was clicked"); });
}

Example 3: Removing the JavaScript click handler of a RadRadioButtonList.

JavaScript
function Click(sender, args){
	// code
}

function removeEvents()
{
    var radioButtonList = $find("<%= RadRadioButtonList1.ClientID %>");
    radioButtonList.remove_itemClicked(Click);
}

Table 1: Available add/remove methods for handling client-side events.

NameDescription
add_selectedIndexChangingThe name of the JavaScript function called when the selected index is to be changed.
remove_selectedIndexChangingRemoves a handler for the selectedIndexChanging event.
add_selectedIndexChangedThe name of the JavaScript function called when the selected index is changed.
remove_selectedIndexChangedRemoves a handler for the selectedIndexChanged event.
add_loadThe name of the JavaScript function called when the control loads.
remove_loadRemoves a handler for the clientLoad event.
add_itemClickingThe name of the JavaScript function called when the item is clicked, but before itemClicked event.
remove_itemClickingRemoves a handler for the itemClicking event.
add_itemClickedThe name of the JavaScript function called when the item is clicked.
remove_itemClickedRemoves a handler for the itemClicked event.
add_itemLoadThe name of the JavaScript function called when an item is loaded.
remove_itemLoadRemoves a handler for the itemLoad event.
add_itemMouseOverThe name of the JavaScript function called when the mouse cursor moves over an item.
remove_itemMouseOverRemoves a handler for the itemMouseOver event.
add_itemMouseOutThe name of the JavaScript function called when the mouse cursor moves out of an item.
remove_itemMouseOutRemoves a handler for the itemMouseOut event.

See Also

In this article
See Also
Not finding the help you need?
Contact Support