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

[Solved] OnClientSelectedIndexChanged firing when item is selected server-side

2 Answers 169 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 15 Feb 2010, 05:41 PM
I'm adding items to a RadComboBox server-side like so:

            foreach (ValueMapping mapping in ValueMappings) 
            { 
                RadComboBoxItem comboItem = new RadComboBoxItem(mapping.DisplayValue, mapping.DataValue); 
                this.Items.Add(comboItem); 
            } 

Then later I'm selecting the item I want to be initially selected in the combobox on the server-side too:

                RadComboBoxItem item = 
                    this.FindItemByValue(value); 
 
                if (item != null
                { 
                    item.Selected = true
                } 

I have registered a client-side event listener to the "OnClientSelectedIndexChanged" event. However, this event seems to be firing as soon as the page loads as if the user has selected a value using the combobox. Is this expected behaviour, something broken or me doing something wrong? I only want to be notified when the value has been changed by the user from the value selected server-side - how would I achieve this?

I am using version 2008.3.1314.20

Thanks,
James

Addendum: I've just realised that the client event only seems to be fired once when the page loads and never again. That is, the event is not being fired when the user selects a new item. Help!




2 Answers, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 16 Feb 2010, 03:36 PM
Ignore me - I was being dozy...

I've sorted it out myself now.

I was trying to register an event handler with the wrong method signature. How embarrassing.

Still, it's curious that this causes the method to be called when the page loads.

Try this to see what I mean:

combobox.OnClientSelectedIndexChanged = "alert('Hello World!')";
0
Yana
Telerik team
answered on 18 Feb 2010, 02:05 PM
Hello James,

You are right about this, it's really strange and we'll reasearch the reason for it. Thanks for reporting it.

Regards,
Yana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
ComboBox
Asked by
James
Top achievements
Rank 1
Answers by
James
Top achievements
Rank 1
Yana
Telerik team
Share this question
or