Linkbutton Click event handler not executing

A

Assaf Weinberg

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
 
M

Marina

Dynamic controls need to be recreated on postback for their event handlers
to run.
 

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

Top