How to capture dynamically a button click on a usercontrol, and in page?

D

davidr

Hi,

I've read about bubble events and setting up the event args and several
other methods to have an event that occurs in a usercontrol flow up to
the parent. The problem is each one entails a lot of coding for just
one use control. Well, I have many user controls and am looking for a
very simple and universial approach. The problem is: I have a webpage
test.aspx and on it I can load any user control I want based on what
the user selects from a menu. Once the usercontrol is up. I want to
say click Save, do my database updates with the click event. Then
after that I want to load in a new usercontrol from the Main webpage.
Considering the size the application will be when someone clicks a
button, or save, or anything I can load many different user controls.
So is there a simple approach that I could take to call my public
LoadNewUserControl(usercontrolfile) method I have in the parent class?

I've seen people do something like this in the Button Click event
inside the user control, but it didn't work for me. The test class
doesn't exist or isn't a type that I can cast too.

Page aPage = (test) this.Parent;
aPage.LoadNewUserControl(test5.ascx);

Nor does this work:

this.Parent as test;

Anyways, Please a few recommendations on how to approach this.

Thanks,

David
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top