Can I stop a post back by using javascripts confirm?

前端 未结 1 1282
时光取名叫无心
时光取名叫无心 2021-01-18 13:11

I have an aspx page with a asp.net button on the page:



        
相关标签:
1条回答
  • 2021-01-18 13:41

    You have to return the value from the function in the event handler:

    OnClientClick="return ConfirmDelete();"
    

    By the way, you don't need all that logic in the function, just return the result from the confirm call:

    function ConfirmDelete() {
      return confirm("Are you SURE you want to delete this item?");
    };
    
    0 讨论(0)
提交回复
热议问题