简体   繁体   English

带是否取消按钮的MessageBox

[英]MessageBox with Yes No Cancel Button

<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>

<asp:Button ID="Button1" runat="server" style="font-size: medium; font-weight: 700; font-style: italic" Text="Submit" onclick="Button1_Click" OnClientClick="Confirm()" />

i am using this script but when click on Button1, it does not check RequiredFieldValidator. 我正在使用此脚本,但是单击Button1时,它不会检查RequiredFieldValidator。 please correct my code. 请更正我的代码。

May be this can help you if you are using a web page. 如果您使用的是网页,可能会对您有所帮助。 Instead of writing script in the label, you can use Clientscript like this : 您可以像这样使用Clientscript来代替在标签中编写脚本:

Page.ClientScript.RegisterStartupScript(GetType(), "script", "confirm('" + MessageToDisplay + "');", true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM