Access Parent Page function from User Control

D

David Lozzi

Hello,

I have a user control that saves data. When the data is saved, I need to
call a function in the parent page from the user control to initiate
something else. I know I can set it up so that the save button is in the
parent page and calls the save function of the user control and then
whatever I need from the parent page, but I'd rather keep the save button in
the user control as I am going to be using the same control elsewhere.

Any ideas?

Thanks,
 
G

Guest

Hi David,

You might consider defining custom events in your child control (e.g.
SaveCompleted event and OnSaveCompleted event delegate). The custom control
would raise the event after it finished its function. The parent control
would wire up an event handler to continue processing afterwards. This
gives you greater flexibility in passing customized information in the event
argument to the parent that will handle the event. For examples on how to
define events arguments and event delegates in VB.net:
http://www.societopia.net/Samples/DataGrid_ChildControlsEvents.aspx
and in C#.net: http://www.societopia.net/Samples/DataGridEventDelegates.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top