I want to show a confirm dialog when the user selects an item in a DropDownList. If the user presses \"Cancel\", I want to stop the postback. Here is the function I add to the o
After reading this solution, I just removed the AutoPostBack on my DropDownLists and used this because it was so simple:
$("#DropDownList1").change(function (e) {
if ($(this).val() == "0") {
//do nothing
}
else {
//do postback
setTimeout("__doPostBack('DropDownList1','')", 0);
}
});
or if you have multiple DropDownLists you want to make AutoPostBack:
$("select").change(function (e) {
if ($(this).val() == "0") {
//do nothing
}
else {
//do postback
setTimeout("__doPostBack('" + this.id + "','')", 0);
}
});