Identify control that caused postback

J

Joey G

How do I get the name or identify the control that caused
the page postback. I need the information during page
init. Reason why, because I need to tell usercontrol_1
that usercontrol_2 button was clicked and therefore need
usercontrol_2 public properties to be passed to
usercontrol_1 public properties in the case of the event.

thanks
 
S

Scott M.

The page load event (as well as most other controls) has a Sender as Object
argument. Sender is the object that cause the event handler to fire.

If you use Sender.GetType.Name, you can get the name of the type that caused
the postback.
 
J

Joey G

Thanks for the response Scott, but that is not the case. I felt the same
way, but the object that caused the postback is only the sender of the wired
event (i.e. usercontrol_2_button_click(byval sender as....)) and not the
sender of the page_init or page_load.
 
G

Guest

Maybe you're headed down a better path, but for communicating among user
controls I'd instead raise events--i.e. your user controls each raise a
different event on button click, and your other controls, page, etc. can
listen for it if they want. This makes it much easier to orchestrate, say, in
cases where you use the same controls on multiple pages.

Bill
 

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,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top