473,320 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Linkbutton Click event handler not executing

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
1 13532
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: CodeRazor | last post by:
Hi, I am trying to dynamically create linkbuttons. They need an event handler, so i can respond to the user's click. I try to add the eventhandler on the fly, but when i click on the link, the...
3
by: CodeRazor | last post by:
I am creating an aspx page using C# and would like to be able to dynamically create linkbuttons that all run the same fuction on the click event. However, I would like the function to accept a...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
2
by: prashant khandalkar via DotNetMonster.com | last post by:
Hello everyone. I am using asp:linkbutton in my web page. But when i click on the linkbutton it is not firing the click event please help me. It's urget my email address is pkhandalkar@gmail.com....
1
by: Assaf Weinberg | last post by:
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...
1
by: geronimi | last post by:
I want to create a linkbutton in a cell because not every row needs one (so I can't setup a linkbuttoncolumn instead of a boundcolumn.) First, i create a linkbutton in the datagrid_ItemDataBound...
3
by: Gabe | last post by:
Hi there, The other day I tried to programmatically create an asp.net linkbutton during my Page_Load() event and attach a click event handler to the linkbutton, then add that linkbutton control...
0
by: OceanBreeze | last post by:
I have added a LinkButton to a table cell programmatically inside the Page_Load method. I also added a custom event to that link button. The same custom event is valid for all the link buttons. The...
5
by: =?Utf-8?B?TWFyYyBXb29sZnNvbg==?= | last post by:
Hi, I have a strange issue occurring with LinkButtons that are dynamically added to each (data) row of my DataGrid on that grid's ItemDataBound event. Each LinkButton is assigned its own event...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.