confirm message box before deleting
Posted on 2004-10-01
When clicking on a button (BtnDelete) on my mypage.aspx, I want to show a messagebox to confirme before deleting. I tried with the code below but nothing happens and the information is deleted from the database without any message box appearing. can you add the appropriate code to the code below so that it will work. Thanks.
Private Sub BtnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDelete.Click
'Shows a confirmation box when button delete is clicked
BtnDelete.Attributes.Add("onclick", "return confirm('are you sure you want to delete? ');")
'Declare objects and create a connection
Dim myConnection As OdbcConnection = New OdbcConnection(ConfigurationSettings.AppSettings("connectionString"))
Dim CmdString As String = "Delete From Kunder Where (ordernr = ? )"
Dim myCommand As New OdbcCommand
'Get parameter values from admin_kund.aspx
Dim strOrdernr As String
strOrdernr = Request.QueryString("ID")
myCommand.Connection = myConnection
myCommand.CommandText = CmdString
Catch ex As Exception