Dynamic Link Buttons

B

brian

This is the first time I have tried to create dynamic
controls. I am trying to create a hyperlink control.
The control will display properly but the event isn't
triggered.

I read a lot of stuff pertaining to this topic but have
not been able to figure out my problem. TEST() is
processed when I click a command button which creates the
dynamci link buttons. The dynamic link buttons display
fine but have no event when clicked.

Can someone please give a few suggestions.

Thanks

Private sub TEST()
'All variables have been declared. Left them out to save
'Room
l.Text = JobParsed
l.ID = 1
l.CommandName = "Link"
LinkControl.Controls.Add(l)
AddHandler l.Click, AddressOf l_Click
Next
End Sub

Public Sub l_Click(ByVal Sender As Object, ByVal E As
System.EventArgs)
Response.Write("Button Clicked")
End Sub
 
B

bruce barker

I assume you are creating the controls on a button click. when the postback
from the hyperlink happens you need to recreate the controls (say in form
load) and reassign the handlers. you can save a flag to do this in viewstate
or a hidden field.

-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top