Last Updated: 22 Apr 2019 13:10 by ADMIN
Created on: 19 Apr 2019 11:06
Category: ListBox
Type: Bug Report
Selected index is not persisted after canceling OnClientSelectedIndexChanging event
I have a few instances where I need OnClientSelectedIndexChanging inorder to stop the listbox selectedIndexChanged event from posting back in certain cases. In those cases I stop it from posting back by setting the e.set_cancel(true);

function CheckForListBoxReorder_OnClientEvent(sender, e) {
    if (ListboxReordered()) {
        alert('Please save changes to the bus order.');

This works very nicely, but I'm getting many errors because although it looks like it's still selected to the proper row in the listbox the selectedIndex is now -1.
1 comment
Peter Milchev
Posted on: 19 Apr 2019 11:08
Hello Devora,

Thank you for reporting this issue, as a temporary workaround, the following approach can be used: 

    function OnClientSelectedIndexChanging(sender, args) {
        var chkb = $find("<%= RadCheckBox1.ClientID %>");
        if (chkb.get_checked()) {
            var selectedItem = sender.get_selectedItem();
            if (selectedItem) {

Peter Milchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.