470,631 Members | 1,526 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,631 developers. It's quick & easy.

Identify control that caused postback

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
Nov 18 '05 #1
5 4909
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.
"Joey G" <an*******@discussions.microsoft.com> wrote in message
news:19****************************@phx.gbl...
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

Nov 18 '05 #2
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.

"Scott M." <s-***@nospam.nospam> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
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.
"Joey G" <an*******@discussions.microsoft.com> wrote in message
news:19****************************@phx.gbl...
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


Nov 18 '05 #3
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

"Joey G" wrote:
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

Nov 18 '05 #4
Hi,
How can I know which button cause the postback event in page_load event?
Thanks
"Joey G" wrote:
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.

"Scott M." <s-***@nospam.nospam> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
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.
"Joey G" <an*******@discussions.microsoft.com> wrote in message
news:19****************************@phx.gbl...
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



Nov 19 '05 #5
Hi,

See my blog post:

http://blogs.aspadvice.com/joteke/ar...8/05/1444.aspx

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU

"william" <wi*****@discussions.microsoft.com> wrote in message
news:92**********************************@microsof t.com...
Hi,
How can I know which button cause the postback event in page_load event?
Thanks
"Joey G" wrote:
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.

"Scott M." <s-***@nospam.nospam> wrote in message
news:er**************@TK2MSFTNGP12.phx.gbl...
> 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.
>
>
> "Joey G" <an*******@discussions.microsoft.com> wrote in message
> news:19****************************@phx.gbl...
>> 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
>
>


Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jeff Voigt | last post: by
9 posts views Thread by Joe | last post: by
5 posts views Thread by Nathan Sokalski | last post: by
3 posts views Thread by John Smith | last post: by
4 posts views Thread by PokerMan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.