473,497 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5016
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1640
by: Jeff Voigt | last post by:
Is there any way to dynamically get the name of the control that caused the postback? Since SmartNav is not working for me I'm trying to implement a way to scroll to the control that caused the...
7
5714
by: moondaddy | last post by:
I'm building a page in vb.net with several user controls on it. I'm using user controls instead of a frames page since I've seen this recommended many times in this user group. I want just one of...
9
7494
by: Joe | last post by:
I have a DataGrid with a templated column that displays ImageButtons. I need to know if one of these buttons caused the postback or just another button on the form. If one of these buttons caused...
3
2537
by: Martin | last post by:
Hi, I have created a composite control that has a number of standard asp.net controls on it that can themselves cause postbacks. What i need to do in my composite control is to determine which...
5
2672
by: Nathan Sokalski | last post by:
I have a DataList that I was having trouble getting the events for. After a bit of help, I realized that I needed to put the databinding inside an If Not IsPostBack() condition. Although this fixed...
3
1033
by: John Smith | last post by:
How can I find out which control performed PostBack?
1
1441
by: John Google | last post by:
Hi, I'm using VS2005 .NET 2.0. I want to have a single context menu on a form and link it to various controls via the ContextMenuStrip property of each control. Then I want to dynamically...
4
1530
by: PokerMan | last post by:
Hi I have a few controls on apage that cause a postback. But want to handle a postback differently depending on which one of these controls fired the postback. How do we do this? c#. Thanks
1
2066
by: Pramod K S | last post by:
Hello, How to identify control characters in a url and remove those using php? Thanks.
0
7121
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6993
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.