Item selection client event.

2 posts, 1 answers
  1. Ivy
    Ivy avatar
    30 posts
    Member since:
    Feb 2013

    Posted 12 Nov 2013 Link to this post

    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
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Nov 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top