سؤال

I am developing a composite control for an ASP.NET application and just by chance initially developed the control to use an ITemplate to create its child controls. There will be a series of buttons within the child controls that are to be handled in the root control. I am using the OnBubbleEvent with CommandName/CommandArgument properties on the buttons to wire it all up. And everything worked great... until I changed the templates to controls.

When I converted the template to a Control and called Controls.Add(new ChildControl()) in my root control instead of InstantiateIn(this), event bubbling no longer works.

Any idea why?

(Everything, and I mean everything, else is the same.)

هل كانت مفيدة؟

المحلول

Your composite control must implement INamingContainer interface in order to receive OnBubbleEvent calls. The CompositeControl class already implements this interface... in your case it stopped working not because of ITemplate thing, but because you changed inheritance from CompositeControl to Control.

See this: http://msdn.microsoft.com/en-us/library/system.web.ui.control.onbubbleevent.aspx

they say it there.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top