2
Answers

javascript confirmation message for deleting an item from datalist

Sneha Mishra

Sneha Mishra

16y
5.5k
1
I have a photogallery menu. Inside it I have kept many albums. Inside each album, there are many photos. When I click on the album it is redirected to the photo page. I have followed the orkut site. For each album and each photo I have kept edit and delete buttons.
 
My question is, when I am deleting it should show a message box asking "Are you sure you want to delete? "
 
In both the cases (in case of albums page as well as incase of photos page) I have taken a datalist. In its itemtemplate I have taken the link buttons for edit and delete.
 
 
For deleting I have written the following code in its code behind.
 
Sub Delete_Command(ByVal sender As Object, ByVal e As DataListCommandEventArgs)
Dim id As String
id = dlAlbum.DataKeys(e.Item.ItemIndex)
con = New SqlConnection(conn)
Dim str As String = "Delete from Album_Images where ID=" & id
com = New SqlCommand(str, con)
Try
con.Open()
com.ExecuteNonQuery()
Response.Write(strDeleteMessage)
Catch e1 As Exception
Response.Write("<Script>alert('" & e1.Message() & "');</Script>")
End Try
'for binding the data in grid after deletion
ShowGrid()
End Sub
 
Then in its html page I have called the delete function like below:
 
<asp:LinkButton id="delete" Text="Delete" CommandName="Delete" Runat="server"></asp:LinkButton>
 
 
You please tell me how that alert message

Answers (2)
Next Recommended Forum