OnClientClick return confirm() in ajax environment , event lose

Confirm function on button. We are use OnClientClick="return confirm('Are you sure')" often.

but that is no correct under Ajax. because the real code is Generate return confirm('Are you sure'); __doPostBack('ctl00$ContentPlaceHolder1$lbRestore','')
because the button is normal button and use onclick event no submit type.

So the event is lose.


Please use


if (!confirm('Are you sure?')){return false;}
原文地址:https://www.cnblogs.com/lovebanyi/p/1316158.html