I've a user control registered in an aspx
page
On click event of a button in the user control, how do i call a method which is there in the parent page's codebehind?
Thanks.
asp.netcuser-controlswebusercontrol
I've a user control registered in an aspx
page
On click event of a button in the user control, how do i call a method which is there in the parent page's codebehind?
Thanks.
Best Answer
Here is the classic example using events as suggested by Freddy Rios (C# from a web application project). This assumes that you want to use an existing delegate rather than make your own and you aren't passing anything specific to the parent page by event args.
In the user control's code-behind (adapt as necessary if not using code-behind or C#):
In the page itself you subscribe to the event with something like this: