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

Posted on 2011-05-12
Medium Priority
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
  • 2
LVL 17

Expert Comment

by:Jesse Houwing
ID: 35753105
Instead of Hyperlink, try LinkButton.

Author Comment

ID: 35754303
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

Jesse Houwing earned 2000 total points
ID: 35754321
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

839 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