dynamicall adding user controls to a webform that will act as triggers to Ajax update panel

Posted on 2011-05-12
Last Modified: 2012-05-11
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?
Question by:twestfall
    LVL 17

    Expert Comment

    Instead of Hyperlink, try LinkButton.

    Author Comment

    I actaull ended up changing it all over to a grid instead of a "build on the fly" table.  And used buttons in the table that actually do not look like buttons at all.  I can easily change them to red when they are clicked but not sure how to change them back when a different one is clicked.  Baby steps....
    LVL 17

    Accepted Solution

    You can loop through all the rows in the grid and disable/change the colour of  the other buttons when you need to.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now