Link to home
Start Free TrialLog in
Avatar of lakshmidurga
lakshmidurga

asked on

How to use confirmation box on button click in asp.net,vb.net

Hi,

When user clicks on a button i need to display him a message with ok and Cancel buttons.If the user chooses ok continue with the other logic in that button click ,else if user click cancel then show the same screen to user without continuing the logic in button_click.

I want to know the logic or example code for this.
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Hi lakshmidurga,

The "normal" is to have Yes/No but you can do this
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim msg As String = "Do you want to continue ?"
        Dim result As MsgBoxResult = MessageBox.Show(msg, "Title", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
        If result = MsgBoxResult.Ok Then
            ' do your code
        End If
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal 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