BtnAddRec.Attributes.Add("onclick", "javascript:return confirm('Message Here')")
I'm using this code in the btnAddRec click event, but it's not giving me the message. Is this correct?
Printable View
BtnAddRec.Attributes.Add("onclick", "javascript:return confirm('Message Here')")
I'm using this code in the btnAddRec click event, but it's not giving me the message. Is this correct?
if you put that in the click event of btnAddRec, you'll have to hit the button twice for it to work. Put it in the page_load and it'll work first time out.
I can't put it in the page load event because the button is from inside a datagrid. Is there something else I can do to get the message box to show?
Code:Public Sub DeleteBid(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.DeleteCommand
'check which row has been selected
Dim selectedRow As String = DataGrid1.DataKeys(e.Item.ItemIndex)
Dim btnDelete As Button
btnDelete = e.Item.Cells(4).Controls(0) '<---5th column, first control
btnDelete.Attributes("onclick") = "javascript:return confirm('Are you sure you want to delete \n Bid Record " & selectedRow & "?')"
Add it to the 'ItemDataBound' event handler for the datagrid. This event fires evertime an item is bound to a datasource.
I placed it in the itemDataBound event. I'm getting an "Index out of range error" because no row has been selected yet....