Home All Groups Group Topic Archive Search About

Dynamically added WebControls requiring TWO clicks to fire event?!?

Author
7 Jun 2005 3:49 PM
iamurbal
Any help would be much appreciated.  I am fairly well versed in .Net
and feel I am perhaps "almost there", I must be missing something
small.

Issue
------
I have an asp:table that I am dynamically adding imageButton controls
to.  After I add the image button to the row, I add an eventHandler to
the control.  Now the imageButton renders fine.  Now when i click the
image button, the event does _not_ fire.... BUT, if I click the exact
same control a second time, the event handler fires.

I have tried searching and researching and everything I've found leads
to the page build order and suggestions I have read all refer to
building the control in the page_init() rather than the page_load()
event, which I have tried, yet I still get the same results.  Here's
the gist of the code...

code
------

sub page_init()

     InitializeComponent()

     ' Call sub to dynamically build table and add controls
     loadMenus()

end sub

sub loadMenus()

     ' Build row...
     ' Create imageButton...
     ' Add imageButton to row...
     ' Add eventHandler to _command() of imageButton...
     ' Add row to table...

end sub

sub imageButton_command()

     ' Get command arguments to see which menuItem was clicked...
     ' store menuID and menuItemID in variables

     ' now call loadMenus again with my new ID's
     loadMenus()
end sub


Any help is greatly appreciated.

-e