This is a migrated thread and some comments may be shown as answers.

Item selection client event.

1 Answer 168 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ivy
Top achievements
Rank 1
Ivy asked on 13 Nov 2013, 03:17 AM
Hi
I cant find an event that will fire on selecting an item from the combobox apart from the selectedindexchanged which does not fire on repeatedly selecting the same item. So is it possible to fire a client event on selecting an item?

Thanks
Ivy

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 13 Nov 2013, 07:25 AM
Hi Ivy,

By default, there is no client side item click event for the RadComboBox. You can try the following code to add click event to RadComboBox items from C# code.

ASPX:
<telerik:RadComboBox ID="RadComboBox1" runat="server" EmptyMessage="Select" OnPreRender="RadComboBox1_PreRender">
    <Items>
        <telerik:RadComboBoxItem runat="server" Text="Item 1" Value="1" />
        <telerik:RadComboBoxItem runat="server" Text="Item 2" Value="2" />
        <telerik:RadComboBoxItem runat="server" Text="Item 3" Value="3" />
    </Items>
</telerik:RadComboBox>

C#:
protected void RadComboBox1_PreRender(object sender, EventArgs e)
{
    foreach (RadComboBoxItem item in RadComboBox1.Items)
    {
        item.Attributes.Add("onclick", "ItemClick('" + item.Text + "','" + item.Value + "');");
    }
}

JavaScript:
<script type="text/javascript">
    function ItemClick(text, value) {
        alert("Item Clicked with Text :" + text + " Value : " + value);
    }
</script>

Thanks,
Shinu.
Tags
ComboBox
Asked by
Ivy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or