Issue with preventing postback from client side (RadComboBox SelectedIndexChanged event)

I was doing some validation with a button on client side and if it failed, wanted to prevent from postback. This worked fine with button and client side event, by something like,


Approve


Here, WarningForIncreasingLimit() fires a confirmation dialog box and if the result is cancel, we return “false” hence preventing postback.
Here is the body,
function WarningForIncreasingLimit() {
if (/*some calculation logic here*/) {
result = confirm("Some confirmation message, are you sure you want to continue?");
}
else {
result = true;
}
}

But it does not work when you use a RadComboBox with OnClientSelectedIndexChanged event.
I had a client event like
function radCmbMoveToClientChaneged(sender, eventArgs) {
if (successful logic here)
return true;
else {
var result = WarningForIncreasingLimit();
return result;
}
}

Even if WarningForIncreasingLimit() above returns false, the method won’t prevent postback.
After some r&d , I figured that you have to the changing event instead on changed and set proper in set_cancel method like this.
function radCmbMoveToClientChanging(sender, eventArgs) {
if (successful logic here)
return true;
else {
var result = WarningForIncreasingLimit();

if (!result) {
eventarqs.set_cancel(true);
}

return result;
}
}

No comments:

LinkWithin

Related Posts with Thumbnails