本文介绍了YES或NO的MessageBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何我显示删除记录之前确认消息框?按钮应 NO 而已。没有确定取消。我有这个code,但它仅适用于C#的WinForms ...

 如果(MessageBox.Show(删除备案号。+ numID.Text +?,确认用户删除,MessageBoxButtons.YesNo,MessageBoxIcon.Question)==的DialogResult 。是)
{
    // codeS删除记录
}


解决方案

 < HTML的xmlns =htt​​p://www.w3.org/1999/xhtml>
< HEAD>
    <标题>< /标题>
    <脚本类型=文/ JavaScript的>
        功能确认(){
            VAR confirm_value =使用document.createElement(INPUT);
            confirm_value.type =隐藏;
            confirm_value.name =confirm_value;
            如果(确认(你要保存的数据?)){
                confirm_value.value =是;
            }其他{
                confirm_value.value =否;
            }
            document.forms [0] .appendChild(confirm_value);
        }
    < / SCRIPT>
< /头>
<身体GT;
    <表ID =form1的=服务器>
      < ASP:按钮的ID =btnConfirm=服务器的OnClick =OnConfirm文本=提升确认的OnClientClick =确认()/>
    < /表及GT;
< /身体GT;
< / HTML>

检查此链接:

<一个href=\"http://aspsnippets.com/Articles/Server-Side-$c$c-Behind-Yes-No-Confirmation-Message-Box-in-ASPNet.aspx\" rel=\"nofollow\">http://aspsnippets.com/Articles/Server-Side-$c$c-Behind-Yes-No-Confirmation-Message-Box-in-ASPNet.aspx

How to I display a confirm message box before deleting records? Buttons should be YES or NO only. Not OK or CANCEL. I have this code but it only works for c# winforms...

if (MessageBox.Show("Delete record no. " + numID.Text + "?", "Confirm User Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
    //codes to delete records
}
解决方案
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type = "text/javascript">
        function Confirm() {
            var confirm_value = document.createElement("INPUT");
            confirm_value.type = "hidden";
            confirm_value.name = "confirm_value";
            if (confirm("Do you want to save data?")) {
                confirm_value.value = "Yes";
            } else {
                confirm_value.value = "No";
            }
            document.forms[0].appendChild(confirm_value);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
      <asp:Button ID="btnConfirm" runat="server" OnClick = "OnConfirm" Text = "Raise Confirm" OnClientClick = "Confirm()"/>
    </form>
</body>
</html>

Check this link:

http://aspsnippets.com/Articles/Server-Side-Code-Behind-Yes-No-Confirmation-Message-Box-in-ASPNet.aspx

这篇关于YES或NO的MessageBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 11:44