How to make a simple yes/no popup in ASP.NET that return the result back to my c#?

前端 未结 7 980
再見小時候
再見小時候 2020-12-21 01:05

With ASP.NET, how do I prompt the user for a yes/no question and getting the result back to my .ascx?

So far I can open a confirmation dialog with use of Javascript,

相关标签:
7条回答
  • 2020-12-21 01:41

    Another option is to show yes/no:

    <script>     
            function AlertFunction() {
                if (confirm('Are you sure you want to save this thing into the database?')) {
                   $('#ConfirmMessageResponse').val('Yes');
                } else {
                    $('#ConfirmMessageResponse').val('No');
                }
            }
        </script>
    

    to handle it from .net side:

    string confirmValue = ConfirmMessageResponse.Value;
                    if (confirmValue == "Yes")
                    {...}
    
    0 讨论(0)
提交回复
热议问题