473,748 Members | 2,887 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET PostBack Question

I created simple ASP.NET web application to test how AutoPostBack property
in a web control works.

I set AutoPostBack property to be true of a web control. When I run the
application, here's the sequences when I step through the program:

1. Page loaded to the browser
2. Page_Load method is called with non-postback event
3. The user has certain actions on a control
4. Page_Load method is called with postback event
5. A control's event handler is called.

My question is why Page_Load method is called before a control's event
handler? i.e. Should step 4 and step 5 be reversed in order?

My understanding is ONE CONTROL EVENT causes ONE POSTBACK. Event is the
cause, and PostBack is the result. Am I wrong?? Thats why I think a
control's event handler should call first before Page_Load method.

Please advise. Thanks!


`
Nov 18 '05 #1
5 2040
Take a look at:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpguide/html/cpconControlExe cutionLifecycle .asp

Bin song, MCP
-----Original Message-----
I created simple ASP.NET web application to test how AutoPostBack propertyin a web control works.

I set AutoPostBack property to be true of a web control. When I run theapplication, here's the sequences when I step through the program:
1. Page loaded to the browser
2. Page_Load method is called with non-postback event
3. The user has certain actions on a control
4. Page_Load method is called with postback event
5. A control's event handler is called.

My question is why Page_Load method is called before a control's eventhandler? i.e. Should step 4 and step 5 be reversed in order?
My understanding is ONE CONTROL EVENT causes ONE POSTBACK. Event is thecause, and PostBack is the result. Am I wrong?? Thats why I think acontrol's event handler should call first before Page_Load method.
Please advise. Thanks!


`
.

Nov 18 '05 #2
Hello

The event handler didn't cause the post back, the user's browser did by
submitting the form.
The event took place in the browser then the user took the action for the
control.
Then the form is posted to the server.
Then event handler is executed to take appropriate action base on the event,
such as updating a database.

"Matthew Louden" <ma*******@hotm ail.com> wrote in message
news:e$******** ******@TK2MSFTN GP12.phx.gbl...
I created simple ASP.NET web application to test how AutoPostBack property
in a web control works.

I set AutoPostBack property to be true of a web control. When I run the
application, here's the sequences when I step through the program:

1. Page loaded to the browser
2. Page_Load method is called with non-postback event
3. The user has certain actions on a control
4. Page_Load method is called with postback event
5. A control's event handler is called.

My question is why Page_Load method is called before a control's event
handler? i.e. Should step 4 and step 5 be reversed in order?

My understanding is ONE CONTROL EVENT causes ONE POSTBACK. Event is the
cause, and PostBack is the result. Am I wrong?? Thats why I think a
control's event handler should call first before Page_Load method.

Please advise. Thanks!


`

Nov 18 '05 #3
you have it slightly wrong. onload fires after all controls defined on page
have been created and their data loaded from the postback data if any.

browser requests page ->>

server
OnInit
OnLoad (form load)
OnPreRender
SaveViewState
Render
OnUnload
<<-- rendered page sent to browser

browser loads page
user clicks on something to do postback
browser posts form data --->

server
OnInit
LoadViewState
LoadPostBackDat a (loads controls with postback data)
OnLoad (form load)
RaisePostDataCh angedEvent (controls raise data change event here)
RaisePostBackEv ent (controls raise postback events here)
OnPreRender
SaveViewState
Render
OnUnload
<<-- rendered page sent to browser

browser loads page
you can see from the page create cycle, that OnInit is the last chance to
create dynamic controls that load postback data. OnPreRender is the last
chance to add/change controls that will actually render.

-- bruce (sqlwork.com)

"Matthew Louden" <ma*******@hotm ail.com> wrote in message
news:e$******** ******@TK2MSFTN GP12.phx.gbl...
I created simple ASP.NET web application to test how AutoPostBack property
in a web control works.

I set AutoPostBack property to be true of a web control. When I run the
application, here's the sequences when I step through the program:

1. Page loaded to the browser
2. Page_Load method is called with non-postback event
3. The user has certain actions on a control
4. Page_Load method is called with postback event
5. A control's event handler is called.

My question is why Page_Load method is called before a control's event
handler? i.e. Should step 4 and step 5 be reversed in order?

My understanding is ONE CONTROL EVENT causes ONE POSTBACK. Event is the
cause, and PostBack is the result. Am I wrong?? Thats why I think a
control's event handler should call first before Page_Load method.

Please advise. Thanks!


`

Nov 18 '05 #4


I have asp:label on the page,
on submit i am opening crystal report
and changing the label on the page also .but
some how its not changing the label text but it opens the crystal report
is postback help me to change the label text which i am changing in

sub onsubmit_click
label1.text = "done"

'open crystal report

end sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #5
Is your submit a HTML button or Server Button?
Nov 18 '05 #6

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

Similar topics

2
4062
by: JollyK | last post by:
Hi friends, This is my question.... From the Page Load event (or Page Init event), I would need to find which event had occurred that caused a PostBack, for example was it a event fired from the datagrid that caused a postback, or was it from a linkbutton, or was it from any other control on the page that have PostBack capabilities ? I am pretty sure this information is captured somewhere before the event is sent to its appropiate...
3
2498
by: Jeremy | last post by:
I have an ASPX page with a bunch of System.Web.UI.WebControls.Button controls on it. By default, clicking on any of these causes a Postback. I'd like to have it so that for a couple of these buttons, no PostBack occurs - and rather some client-side script is executed (with no postback subsequently occuring). I have wired up the client-side script to the Buttons in question using Attributes.Add(blah blah blah) - now I just need to somehow...
9
375
by: Robert Galvin | last post by:
Is it possible to tell which control caused a postback?
3
1139
by: Aleksandr Ayzin | last post by:
Hi, Basic question about PostBack: would it be accurate to say that PostBack is a direct result of triggered event that happened on the form(button clicked, text typed into textbox, so on). Is that the only way to trigger postback (esides AutoPostBack = True)or some other actions might initiate it? Thanks, --Alex
21
24461
by: Martin Eyles | last post by:
I am trying to get javascript to cause a page to post back. I have tried calling _doPostBack from my script, but generates an error "object expected". I think this is because the page's script doesn't contain the method _doPostBack, which needs to be added by asp.net. How can I make asp.net add this script? Thanks, ME --
1
3414
by: Marcus | last post by:
I have a problem maybe one of you could help me with. I've created a data entry screen with lots of dynamically-created client-side controls. I create HTML texboxes client-side by assigning a value to the td.innerHTML property. The UI is done, and I now want to post back the user's changes and update my business object in .NET. But when I postback, I can't see any of my dynamically created HTML controls in VB .NET. How do I make them...
8
12774
by: Matt MacDonald | last post by:
Hi All, I have a form that displays hierarchical categories in a treeview. Ok so far so good. What I was to do is have users be able to select a node in the treeview as part of filling out the form. I only want to allow single selection, so using checkboxes is out of the question. It works as is, but it makes the form very cumbersome if every time that a user selects a node, the whole page has to reload. Is there a way to have a node...
2
2412
by: brad | last post by:
Group, I'm using Visual Studio 2003 to create an ASP.NET 1.1 project which contains nested server user controls in order to create a tree-like hierarchy. The tree is a sort of question and answer dialog. The user answers a question, and the next subquestion appears (using dynamic html display:none|block) depending on his answer.
4
5358
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a text field which causes the Autocomplete extender to display 10 like items, after the users selects an item (which is a key in the database) I want the application to go to the database retrieve a record and populate the fields.
0
9544
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
9372
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9324
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9247
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
8243
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
6796
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
6074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.