dynamically adding controls that will act as triggers RRS feed

  • Question

  • 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"


                End If


    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?

    Thursday, May 12, 2011 3:44 PM