Search code examples
c#asp.netupdatepanel

ImageButton event not firing inside Update Panel


This is sort of a follow-up to my question here:

Asp:Label is not shown when visible is set to true?

In the above question, I had a few controls where the visibility was not being set to false because they were not in an UpdatePanel. Once I put the controls inside an UpdatePanel, the toggling of visibility worked, but this has caused me another problem. I have an ImageButton that exports to excel. When the button was not in an UpdatePanel, the click event fired, but now that I put it inside an UpdatePanel, the click event does not fire.

I also have a dropdown which works fine. I am thinking it has something to do with the fact that the ImageButton does not have an AutoPostBack property.


Solution

  • Make sure that you have associated the Image Button to a PostBackTrigger on the UpdatePanel. If you are exporting to Excel using something similar to Matt Berseth's method, you have to have this trigger for the export to work.

    <asp:PostBackTrigger ControlID="ImageButton1"/>