E
Elliot M. Rodriguez
I have a Delete button in my datagrid. I'm attempting to add some code
confirming whether the user wishes to really delete the item or not.
The confirm pops up, but I cannot suppress the submission when selecting
Cancel.
Heres what I have so far:
' adding the javascript call to the button:
Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgItem.ItemCreated
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0), Button)
objDeleteButton.CssClass = "inputbutton"
objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
End If
End Sub
' client side code in javascript
function confirmDeleteItem()
{
if (confirm("Are you sure you wish to delete this item?"))
{
return true;
}
else
{
return false;
}
}
any help is appreciated. thank you.
confirming whether the user wishes to really delete the item or not.
The confirm pops up, but I cannot suppress the submission when selecting
Cancel.
Heres what I have so far:
' adding the javascript call to the button:
Private Sub dgItem_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgItem.ItemCreated
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then
Dim objDeleteButton As Button = CType(e.Item.Cells(1).Controls(0), Button)
objDeleteButton.CssClass = "inputbutton"
objDeleteButton.Attributes.Add("onClick", "confirmDeleteItem();")
End If
End Sub
' client side code in javascript
function confirmDeleteItem()
{
if (confirm("Are you sure you wish to delete this item?"))
{
return true;
}
else
{
return false;
}
}
any help is appreciated. thank you.