Link to home
Start Free TrialLog in
Avatar of Sprocket46
Sprocket46

asked on

MessageBox.YesNo

I have a delete button. Upon click of that button, I have a prompt for with a Yes/No option. I have the "Yes" button working, but the "No" still operates using the "Yes" function. How can I make it call or have it's own function?
Avatar of hiAsh
hiAsh

The code below can be a solution to your query. You can write this in a Javascript function and call the function in the click event of the Delete Button. This code propmts a message box with the Ok and Cancel buttons and on Clicking on OK the code inside the if block will get executed
*******Code Begins here*********

if(confirm("Are you sure you want to delete?"))
{
//Code here if the option is 'OK'
}

*******Code ends here**********

I hope this works for you. All the Best
ASKER CERTIFIED SOLUTION
Avatar of Mohammed Nasman
Mohammed Nasman
Flag of Palestine, State of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sounds like you want:

    Private Sub cmdDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDelete.Click
        If MsgBox("Do you want to delete?", MsgBoxStyle.YesNo, "Confirm") = MsgBoxResult.Yes Then
            Do_Delete()
        Else
            Do_Cancel_Delete()

        End If
    End Sub

    Private Sub Do_Delete()
        'do stuff to delete something

    End Sub
    Private Sub Do_Cancel_Delete()
        'do stuff to not delete something

    End Sub
Avatar of Sprocket46

ASKER

Thank you very much. Works great!