?
Solved

Dynamic linkbutton not triggering event

Posted on 2005-03-21
5
Medium Priority
?
599 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

762 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