468,765 Members | 804 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

Dynamic Link Buttons

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
Nov 18 '05 #1
1 2013
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)
"brian" <bs******@lbrspec.com> wrote in message
news:1a*****************************@phx.gbl...
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

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by MikeY | last post: by
1 post views Thread by brian | last post: by
3 posts views Thread by WebBuilder451 | last post: by
3 posts views Thread by NateDawg | last post: by
2 posts views Thread by WolfyUK | last post: by
5 posts views Thread by Matt | last post: by
5 posts views Thread by Gui | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.