Add onClink on the fly

  • Thread starter Thread starter Rudy Ko
  • Start date Start date
R

Rudy Ko

All,

I have a DataList control on my page. Within that DataList, I have a
Linkbutton. I want to add a OnClick client side script event during
ItemCreated or ItemDataBound event. Can you help?

Thanks,
Rudy
 
probly something like that

Private Sub myList_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataListItemEventArgs) Handles myList.ItemCreated

Dim lb As LinkButton = CType(e.Item.FindControl("lbClick"), LinkButton)
If Not lb Is Nothing Then
lb.Attributes.Add("onClick", "javascript:alert('hello!');")
End If

End Sub
 
Back
Top