Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

In my grid view row command i want to delete the row with confirmation alert box(javascript alert ), upto alert box is working fine , but the problem is , The Row command is fired immediately that is not waiting for alert box
grid control
------------
ASP.NET
<asp:TemplateField ItemStyle-Width="25px" ItemStyle-Height="15px">
                                   <ItemTemplate>
                                      
                                             <asp:ImageButton ID="lnkswi_del" runat="server" CommandName="Delete" ToolTip="Delete"
                                           CommandArgument="<%#CType(Container,GridViewRow).RowIndex%>" ImageUrl="~/Images/delete.png" CssClass="test" OnClientClick="return Confirmdelete();" />
                                   </ItemTemplate>
                               </asp:TemplateField>


javascript
-----------
JavaScript
function ConfirmDelete() {
            alertify.set({ buttonReverse: true });
            alertify.confirm('Are you sure you want to delete the record?', function (e) {
                if (e) {                 
                   
                    return true;
                } else {
                    return false;
                }
            });
        }


code behind
-----------
VB
Protected Sub gridTran_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gridTran.RowCommand

            If e.CommandName = "Delete" Then
                Dim index As Integer = Convert.ToInt32(e.CommandArgument)
                Dim gvRow As GridViewRow = gridTran.Rows(index)
                trxnno = gvRow.Cells(1).Text 
                deletemethod() // this method will delete the row
            End If

after click the alert box ok only the row command event should fire , but its not

help me resolve this

and also , i did it through rowdatabound event, ther also the same problem is occuring
VB
Protected Sub gridTran_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gridTran.RowDataBound
        If (e.Row.RowType = DataControlRowType.DataRow) Then
            Dim theDeleteButton As ImageButton = CType(e.Row.Cells(0).FindControl("lnkswi_del"), ImageButton)
            theDeleteButton.OnClientClick = "return ConfirmDelete();"
        End If
    End Sub


thanks in advance
Velsamy
Posted
Updated 6-Oct-14 1:59am
v2

1 solution

 
Share this answer
 
Comments
avelsamy 1-Oct-14 6:06am    
still its getting that same ....
avelsamy 1-Oct-14 6:08am    
its auomatically getting 'YES' , Row command is not waiting for javascript alert

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900