By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,600 Members | 1,683 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,600 IT Pros & Developers. It's quick & easy.

Linkbutton Click event handler not executing

P: n/a
Using ASP.NET web form with VB.NET

I have a page with a calendar control that
onSelectionChanged builds a table control showing the
events scheduled for the selected calendar days. One of
the columns in this table contains linkbuttons that, when
clicked, should execute some code (currently an event
handler called showEvent) that displays details.

I am currently using addhandler to specify the handler for
the linkbutton click events. When clicked, the
linkbuttons cause a postback, but mysteriously do not
execute the showEvent function.

Here is the code that creates the linkbuttons - it gets
called by the onSelectionChanged of the calendar:

For Each row In editor.dataTable.Rows

Dim tablerow As New TableRow()
Dim dateCell As New TableCell()
Dim titleCell As New TableCell()
Dim officeCell As New TableCell()
Dim link As New LinkButton()
...

'Set linkbutton attributes
link.Attributes("class") = "noDecor"
link.Text = row("eventTitle")
link.ID = "lnk" + CStr(row("eventID"))

'Add click handler
AddHandler link.Click, AddressOf showEvent

'Add all elements to the new tablerow and add
it to the output table
titleCell.Controls.Add(link)
...

Next

Let me know if you have any ideas

Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Dynamic controls need to be recreated on postback for their event handlers
to run.

"Assaf Weinberg" <aw*******@kiesling.com> wrote in message
news:01****************************@phx.gbl...
Using ASP.NET web form with VB.NET

I have a page with a calendar control that
onSelectionChanged builds a table control showing the
events scheduled for the selected calendar days. One of
the columns in this table contains linkbuttons that, when
clicked, should execute some code (currently an event
handler called showEvent) that displays details.

I am currently using addhandler to specify the handler for
the linkbutton click events. When clicked, the
linkbuttons cause a postback, but mysteriously do not
execute the showEvent function.

Here is the code that creates the linkbuttons - it gets
called by the onSelectionChanged of the calendar:

For Each row In editor.dataTable.Rows

Dim tablerow As New TableRow()
Dim dateCell As New TableCell()
Dim titleCell As New TableCell()
Dim officeCell As New TableCell()
Dim link As New LinkButton()
...

'Set linkbutton attributes
link.Attributes("class") = "noDecor"
link.Text = row("eventTitle")
link.ID = "lnk" + CStr(row("eventID"))

'Add click handler
AddHandler link.Click, AddressOf showEvent

'Add all elements to the new tablerow and add
it to the output table
titleCell.Controls.Add(link)
...

Next

Let me know if you have any ideas

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.