|
Subject:
|
Unable to fire a click event
|
|
Posted By:
|
rfinks
|
Post Date:
|
8/29/2006 6:00:59 PM
|
I'm having trouble with link buttons in a datagrid column template, contained in a dynamically loaded user control. I'm unable to get the controls to respond to click events or command events. They don't seem to be firing. I've also tried regular buttons with the same result.
I've got a feeling this is a page life-cycle issue but haven't been able to find an answer. I know that link buttons generate Java Script for client side events. This is not an issue because I've tested link buttons on a form by themselves and they work. I appears that the form is making a round-trip to the server and then reloading the same form instead of redirecting to a different page, which would have happened if the click-event was executed.
Any insight into this issue would be most appreciated.
Roger Finks
|
|
Reply By:
|
dparsons
|
Reply Date:
|
8/29/2006 6:19:55 PM
|
Have you stepped through the code?
Are the link buttons in an EditCommandColumn? If so: In the datagrid, have you set the OnEditCommand, OnUpdateCommand?
If these are just buttons contained in a datagrid, and you need to wire up some functionality to them, in your case, a redirect you could do something like this:
Private Sub dgItemBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles dgRec.ItemDataBound Dim lb As LinkButton If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then lb = CType(e.Item.Cells(0).FindControl("lbDelete"), LinkButton) lb.Attributes.Add("onClick", "return getconfirm();") End If
End Sub
Then each link button will trigger the getconfirm function when it is clicked.
hth.
"The one language all programmers understand is profanity."
|
|
Reply By:
|
rfinks
|
Reply Date:
|
9/1/2006 10:26:44 PM
|
Thanks for the reply. You've exposed me to a different way to accomplish this. I've got the ItemDataBound event to fire. Now I have to write the Javascript function to handle it.
Roger Finks
|