Monday, July 7, 2008

How to add alert Javascript coding for Gridview?

Protected Sub gvcat_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvcat.RowDataBound

' This block of code is used to confirm the deletion of current record.
If e.Row.RowType = DataControlRowType.DataRow Then
Dim l As Object
' e.Row.Controls(4) is Delete button.
l = e.Row.Controls(4)
l.Attributes.Add("onclick", "javascript:return confirm('Are you sure to delete?')")
End If
End Sub

No comments: