I'm looking to, in a certain scenario, remove the "OnSelectedIndexChanged" event from a Telerik RadComboBox.
When the scenario is satisfied, I'm hoping to remove "myRCB_SelectedIndexChanged" and when it's not, leave the event as-is.
I've tried:
myRCB.SelectedIndexChanged -= myRCB_SelectedIndexChanged
And:
myRCB.SelectedIndexChanged -= new RadComboBoxSelectedIndexChangedEventHandler(myRCB_SelectedIndexChanged)
Neither works, and the event still fires upon changing index. I appreciate the help!
Both of the replies led me toward the answer (thank you!). I added breakpoints where necessary, watched when/where the Event Handler was added/removed, and found that the user-experience was still as it existed--the page would still post back and would run the SelectedIndexChanged
event even though the removal was being done and the addition wasn't happening again thereafter.
Doing this, though, gave me the idea to simply disable AutoPostBack
where I was once attempting to remove the Event Handler. Now, instead of solely defining AutoPostBack="true"
in the .aspx, I am, additionally, removing it where necessary in the .cs.
I hope this helps somebody else, because this has had me banging my head on the desk for days!