473,666 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What caused the postback?

How can I tell which control caused a postback? I have several controls
that cause a postback, and I want to take different actions depending on
which was activated. It seems a little backward that the page load runs
first, then last is the actual event that caused the postback, as that last
event is where all the new parameters are. If I can tell what caused the
postback, then I can at least take action accordingly. Or should I be doing
this a different way?

Thanks for your help.
Dec 28 '05 #1
2 1578
Yes, you should be doing things differently.

Take a brief look at the description of the various stages of the page
cycle:
http://msdn.microsoft.com/library/de...nlifecycle.asp

You would typically use the Load event to perform actions common to all
requests. Then during handling the postback events you would realize which
control made a request. Then you can use the PreRender to do what you
probably were trying to do in the Load event.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"news.microsoft .com" wrote:
How can I tell which control caused a postback? I have several controls
that cause a postback, and I want to take different actions depending on
which was activated. It seems a little backward that the page load runs
first, then last is the actual event that caused the postback, as that last
event is where all the new parameters are. If I can tell what caused the
postback, then I can at least take action accordingly. Or should I be doing
this a different way?

Thanks for your help.

Dec 28 '05 #2
I agree with Phillip, you *should* do things the right way

The answer to your first question may lie with the __EVENTTARGET form
value

-- addup --

Dec 28 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2458
by: Bisser Milanov | last post by:
I have few buttons on a page. In Page_Load I would like to determine which one caused post back. How to do?
1
1318
by: Patrick.O.Ige | last post by:
What is PostBack for
9
7507
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 the postback than I don't want to do a DataBind otherwise I do. I know __EVENTTARGET doesn't return this information. Is there anything else that does? Thanks, Joe
3
2213
by: Jordan | last post by:
I am dynamically inserting an html <input> tag as text (equivalent of an image button) into a page via a Literal control. Something like this gets inserted: <input type="image" name="MyImageButton" id="MyImageButton" src="somePic.jpg" /> I want for the code-behind to "know" when the user clicked on the image - but I don't want to also have to dynamically specify a delegate for an event procedure to handle this control which is really...
11
14812
by: antonyliu2002 | last post by:
I know that this has been asked and answered thousands of times. As a matter of fact, I know that I need to say If Not Page.IsPostBack Then 'Do something End If for things that needs to be processed by the web server. I am still struggling to understand this postback logic, and hope that some kind gurus out there could help me clarify the confusion I have.
2
1919
by: Matt B | last post by:
This seems like it has probably been covered many times before, but I'm having a hard time finding any discussion about it (probably just searching the wrong terms). Is there a way to capture whether the Text of a TextBox has been changed by code or the user. I don't care if the Text is changed by code, only if the user changes it. I actually figured out a solution using a flag for the TextBox something like:
6
2430
by: Jonathan Wood | last post by:
Greetings, I have a Website that emails me any time an error occurs. I have debugging on so that it can include page and line number information. So I got a ton of the email below. Unfortunately, while I see it has something to do with having "unsafe" characters in the query string, it doesn't tell me on which page. Line 0 of App_Web_3uw3mai2.5.cs means absolutely nothing to me. And it's too big a site to try and guess.
1
2260
by: ornit | last post by:
What caused this error: c4430?
4
1294
by: Jim Rockett | last post by:
Subject: what caused a Non-numeric error in the C ++ formula below? the curveGR is name of a column of numbers > if( (curveGR+ 0.5) >= (int(curveGR) + 1) ) > cout << curveGR << " rounds to " << int(curveGR)+1; > else > cout << num << " rounds to " << int(curveGR; << > > error is non-numeric
0
8352
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8863
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7378
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6189
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
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 we have to send another system
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1763
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.