UserControl's Event Handler not firing

后端 未结 4 1838
攒了一身酷
攒了一身酷 2021-01-05 15:23

I dynamically load a UserControl into a View that\'s in a MultiView control. Although the UserControl adds an event handler, the event never fires.

What am I missin

4条回答
  •  时光说笑
    2021-01-05 16:06

    Postback event handling is done before rendering so the control is not present in the page in your case.

    The life cycle events are fired in this order (skipped a few):

    1. Init
    2. Load
    3. PreRender
    4. Unload

    And event handling is done between Load and PreRender (in case some events change the way the page should be rendered, it makes sense).

    So just move your code that loads the Retry control to Load or Init.

    Reference: Asp.Net Page Life Cycle Overview

提交回复
热议问题