Eventhandling in ascx usercontrols

后端 未结 3 898
栀梦
栀梦 2021-01-14 05:33

What is best practises for communicating events from a usercontrol to parent control/page i want to do something similar to this:

MyPage.aspx:


        
3条回答
  •  时光说笑
    2021-01-14 05:56

    1) Declare a Public event in the user control

    2) Issue a RaiseEvent where appropriate inside the user control

    3) In the Init event of the parent page, use AddHandler to assign the control.event to the the handling procedure you want to use

    Simple as that!

提交回复
热议问题