在ASP.net中使用“确定”或“取消”选项确认消息框 [英] Confirm Message Box with OK or Cancel option in ASP.net

查看:143
本文介绍了在ASP.net中使用“确定”或“取消”选项确认消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我点击del按钮时,我的页面中有一个删除按钮,它应该要求确认你确定要删除它,如果是,则执行删除过程,如果取消返回到同一页面。



任何人都可以帮助我吗?

I had a Delete button in my page when I click the del button it should ask for the confirmation that "Are you Sure to Delete this", if YES do delete process, if cancel return to the same page.

Can anyone help me?

推荐答案

 <script type="text/javascript">
function DeleteItem() {
            if (confirm("Are you sure you want to delete ...?")) {
                return true;
            }
            return false;
        }
 </script>







<asp:button id="Button1" runat="server" text="Delete" onclientclick="return DeleteItem()" xmlns:asp="#unknown" />


<body>

<p>Click the button to display a confirm box.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction()
{
var x;
var r=confirm("Press a button!");
if (r==true)
  {
  x="You pressed OK!";
  }
else
  {
  x="You pressed Cancel!";
  }
document.getElementById("demo").innerHTML=x;
}
</script>

</body>







试试这个js实现




Try this js implementation


这是另一个完全相似的问题已经解决:



在ASP .Net中创建警报或确认框 [ ^ ]
Here is another exact similar question that has been solved:

Creating alert or confirmation box in ASP .Net[^]


这篇关于在ASP.net中使用“确定”或“取消”选项确认消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆