When developing a complex page, the page is often used. the loadcontrol method obtains the user control and adds it to the Web Container Control. Usually, it is a placeholder or panel.
(In. In dottext, placeholder is inherited from panel)
During development, I defined an event in the user control and tried to let the page handle the event.
At this time, I found a problem. Originally, I triggered a button in a user control. This button event was defined on the page for processing, but it was not reflected at this time. This button event can be triggered only once.
Because every time I load the page, I will determine which user control to load based on the relevant parameters. The registered event is invalid at this time.
If I do not load it dynamically, it is no problem that the user control uses event Delegate to handle it on the page.
Therefore, I suggest that if you can determine the user control, you can use event Delegate and hand in page processing.
If the user control is dynamically loaded, it is best not to use event delegation and hand in page processing (this message transmission mechanism ).