ASP.Net Confirm box issue

前端 未结 2 1134
北恋
北恋 2021-01-17 01:51

In my asp.net application I have used JavaScript confirm box for user confirmation. Here is the code:

EDIT :



        
2条回答
  •  天命终不由人
    2021-01-17 02:11

    By using javascript confirm method you only decide, whether you want to continue or not - so it is ok that your Button1_Click method is called only when user clicks ok.

    What you trying to do is quite different. I would suggest to get rid of ASP.NET Button control and use "common" HTML link like:

    Click me
    

    And then in javascript

    document.getElementById('decideLink').onclick = function()
    {
        if(proceed) {
            // do something here
        } else {
            // do something different
        }
    }
    

    To call code-behind method from javascript, check this article about calling web methods from javascript

提交回复
热议问题