简体   繁体   English

确认弹出消息 (ASP.NET/VB)

[英]confirmation popup message (ASP.NET/VB)

I want to have a confirmation message box pop up when a user clicks the cancel button on a form.当用户单击表单上的取消按钮时,我希望弹出一个确认消息框。 I believe this would be the correct javascript code:我相信这将是正确的 javascript 代码:

function confirmation() {
        var answer = confirm("Are you sure you want to cancel? Any information you have entered will be discarded.")
        if (answer) {
            window.location = "index.htm";
        }
    }

But, I'm not sure how I can call the function with VB from my code behind page.但是,我不确定如何从我的页面后面的代码中使用 VB 调用 function。

On your cancel button add this markup attribute在您的取消按钮上添加此标记属性

OnClientClick="return confirmation();"

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

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