asp.net vb define public withevents usercontrol dynamically

atanik

New Member
i have a usercontrol called list.ascxcurrently in the class code list.ascx.vb i declare a public withevents variable and set it equal to an instance of another user control (e.g. add_animal.ascx)from this point, i can successfully see the public event "saved" of add_animal and add a handler in list.ascx to execute some code when "saved" event is raised.my problem is the next step. i want to be able to declare my public withevents variable and set it conditionally to any number of custom controls e.g. add_animal.ascx or add_owner.ascx or add_zoo.ascx etc and handle the event "saved" for each of these controls.whichever way i try to initially create my public withevents variable AS Object or AS UserControl or AS Control and then reassign it later with coditional logic to point to the relevent custom control class (e.g. add_animal) i am told that the "saved" event in the resulting variable can not be seen.can anyone please help explain how i can assign this public withevents variable dynamically inside my list.ascx control to any one of my custom controls classes. (an attribute of my list.ascx control tells me which usercontrol i need)many thanks in advanceW
 
Back
Top