Question

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.

Was it helpful?

Solution

On your cancel button add this markup attribute

OnClientClick="return confirmation();"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top