How to prevent AutoPostBack when DropDownlist is selected using jQuery

后端 未结 4 1160
面向向阳花
面向向阳花 2021-01-22 19:32

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

4条回答
  •  粉色の甜心
    2021-01-22 19:36

    I know this question is kind of old, but since it popped up in google search when I needed an answer to it, I will post solution here. I think it is simplier than those posted before.

    I took it from http://forums.asp.net/p/1475520/3432980.aspx:

    
    
    
    

    The key part here is the code within onchage: to cancel AutoPostBack it has to return something (doesn't matter if true or false) and to proceed with AutoPostBack it should not return anything.

提交回复
热议问题