Dynamically Added Event Handler Not Firing

前端 未结 1 1369
走了就别回头了
走了就别回头了 2020-12-22 11:22

Here is a quick code snippet, that doesn\'t seem to work at all for me. I\'m reading from a file to create a list of radio buttons. The problem is that when one of the radio

相关标签:
1条回答
  • 2020-12-22 12:05

    You need to add the button on every postback before events attached to it will fire.

    If you think about it for a moment, it will make sense - if the button has not been created (on the postback), then there are no button events that can fire. The button must exist before events attached to it can be fired.

    The OnInit page event is the most suitable place to add dynamic controls to a page.

    Read about the asp.net page life cycle.

    0 讨论(0)
提交回复
热议问题