Event handler not firing

T

Tom Perkin

Hello all,

I have an ASP.NET page written in VB.NET that dynamically adds rows to
a table from data returned by a database query. Some rows in this table
contain buttons whose events I handle.

In the event handler I rebuild the table adding event handlers again
using addHandler. When the handler has been wired up from Page_load it
fires correctly. When the handler has been wired from within another
event handler it fails to fire. Am I missing something here? Is this
behaviour by design?

warm regards, and thanks in advance,

-tom

The structure is similar to this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
buildPage()
end Sub

private sub buildpage()
' create buttons and add to page
addHandler myButton.Click, addressOf buttonClickHandler
end sub

private sub buttonClickHandler(sender as system.object, e as
system.eventargs)
' Do stuff
buildPage()
end sub
 
T

Tom Perkin

Solved.

I was allowing the IDs to be generated automatically. Because the event
handler changed the layout of the page, the control ID's changed over
the page lifecycle, meaning that the event wasn't hooked.

I solved the problem by explicitly supplying consistent ID's for the
controls I am creating.

-t
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top