I have page ParentPage.aspx
and 2 user controls say (control1.ascx
and control2.ascx
)
On load of page I have dynamically added one of user control depending on condition, Now this ParentPage also have on button which is outside PlaceHolder (which holds Usercontrol) and on click of say (btnNext
Button I want to call respective method of UserControl.
Is it possible to call usercontrol's method on Event of Parent page,
I am trying to Do following for this problem
1. Both userControl will Implementing say IAction
methos which has Action method in it.
2. Page will have Property of type IAction, whose getter will return respective UserControl, and On this IAction Property (on that UserControl I will call Action Method)
But I want to decouple this ParentPage with UserControl and for that I want to use Event but not getting how to do that,
All google links provided, shows how to call parent Page method on click of Usercontrol event but not vise versa.
Delegates
I would quickly read up on how to use them as well as create them inside user controls.. - MethodMan<my:UserControl runat="server" ID="ucControl1" />
Then you can just get it like this in your parent button click eventucControl1.ActionMethod();
- prasy