简体   繁体   中英

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:

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.

On your cancel button add this markup attribute

OnClientClick="return confirmation();"

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