Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Dynamic linkbutton not triggering event

Posted on 2005-03-21
5
Medium Priority
?
602 Views
Last Modified: 2009-07-29
I have a series of LinkButtons that are generated in a for loop:

...
     Dim myLink As New LinkButton
     myLink.Text = "[Edit]"
     myLink.CommandName = "Jump"
     myLink.CommandArgument = dtrReader("stepID")
     myLink.ID = "lbtnEdit_st" + intStep.ToString()
     AddHandler myLink.Click, AddressOf Edit_Click
     phInputTables.Controls.Add(myLink)
...

When I click the LinkButton, Edit_Click does not run. The page posts back but the specified event sub is never triggered... how do I get the LinkButton to trigger the event handler?
0
Comment
Question by:sexyrexy
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13592335
Example from my code:

  AddHandler linkName.LinkClicked, AddressOf ChartLinkClicked

  Private Sub ChartLinkClicked(ByVal sender As Object, ByVal e As LinkLabelLinkClickedEventArgs)

  End Sub 'ChartLinkClicked'

Bob

0
 
LVL 2

Author Comment

by:sexyrexy
ID: 13592367
That's the same code as I am using, except you're using a LinkLabel, so the eventargs is slightly different.
0
 
LVL 2

Author Comment

by:sexyrexy
ID: 13592546
OK, I figured it out. The sub that added the events in the first place wasn't called on postback, so the events weren't re-added when the controls were dynamically built the second time around.
0
 

Accepted Solution

by:
OzzMod earned 0 total points
ID: 13629312
Closed, 200 points refunded.
OzzMod
Community Support Moderator (Graveyard shift)
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Loops Section Overview
Suggested Courses

580 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