How to attach Javascript onto Delete Button in GridView ?
-
Hi, I just switched from .Net 1.1 to .Net 2.0. I want to attach Javascript onto Delete button in GridView so that the user will be able to confirm if he really wants to delete the record. However, I couldn't find ItemCreated event, which is presented in Datagrid. Here is my code used in Datagrid: Private Sub dgContainer_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgContainer.ItemCreated If e.Item.ItemIndex > -1 And Not e.Item.ItemType = ListItemType.EditItem Then Dim DeleteButton As LinkButton = e.Item.Cells(6).Controls(0) 'Attach javascript onto OnClick event DeleteButton.Attributes("OnClick") = "javascript:return confirm('Deleting this client will delete all the information related the client. Do you really want to delete " & _ Chr(34) & Trim(dgContainer.DataKeys(e.Item.ItemIndex)) & Chr(34) & "?')" End If End Sub Does anyone know how to do this in GridView? Thank you in advance!
-
Hi, I just switched from .Net 1.1 to .Net 2.0. I want to attach Javascript onto Delete button in GridView so that the user will be able to confirm if he really wants to delete the record. However, I couldn't find ItemCreated event, which is presented in Datagrid. Here is my code used in Datagrid: Private Sub dgContainer_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgContainer.ItemCreated If e.Item.ItemIndex > -1 And Not e.Item.ItemType = ListItemType.EditItem Then Dim DeleteButton As LinkButton = e.Item.Cells(6).Controls(0) 'Attach javascript onto OnClick event DeleteButton.Attributes("OnClick") = "javascript:return confirm('Deleting this client will delete all the information related the client. Do you really want to delete " & _ Chr(34) & Trim(dgContainer.DataKeys(e.Item.ItemIndex)) & Chr(34) & "?')" End If End Sub Does anyone know how to do this in GridView? Thank you in advance!
Check this article: http://aspnet.4guysfromrolla.com/articles/021104-1.aspx
-
Check this article: http://aspnet.4guysfromrolla.com/articles/021104-1.aspx
-
Enable "AutoPostBack" for the Combo Box you made. can be done through its properties box. By default, this is not enabled ... btw, what would happen if it was enabled by default ... what were going in their minds .. can someone suggest ... kaliem
-
Check this article: http://aspnet.4guysfromrolla.com/articles/021104-1.aspx