In the page life cycle, the internal RaisePostBackEvent
method (which raises the button's Click
event) occurs between OnLoad
and OnLoadComplete
. If you wait until OnLoadComplete
to add the LinkButton
and hook up its Click
event, then obviously the event won't be raised: it's too late.
(The fact that you're using an anonymous method is irrelevant.)
Can you add the export button in the .aspx but set its Visible
property to false when you don't want it to appear?