简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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