dynamicall adding user controls to a webform that will act as triggers to Ajax update panel
Posted on 2011-05-12
I would like to dynamically add controls to a page that would then act as a trigger to an Ajax Update Panel.
Dim tCell As New TableCell()
Dim h As New HyperLink()
h.NavigateUrl = "?PageID=" + DV.Table.Rows(intRowCtr).Item("pageID").ToString
h.Text = DV.Table.Rows(intRowCtr).Item("colorname")
h.ID = "btn" + DV.Table.Rows(intRowCtr).Item("pageID").ToString
This is about as far as I can get. I’ve tried adding code from posts I’ve read to dynamically add the trigger like
Dim AT = New AsyncPostBackTrigger
AT.ControlID = "btn" + DV.Table.Rows(intRowCtr).Item("pageID").ToString
AT.EventName = "Click"
But this doesn’t work either. I get the error Control with ID 'btn44' being registered through RegisterAsyncPostBackControl or RegisterPostBackControl must implement either INamingContainer, IPostBackDataHandler, or IPostBackEventHandler.
Any ideas what to try next?