473,382 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 2021
Take a look at:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpguide/html/cpconControlExecutionLifecycle.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*******@hotmail.com> wrote in message
news:e$**************@TK2MSFTNGP12.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
LoadPostBackData (loads controls with postback data)
OnLoad (form load)
RaisePostDataChangedEvent (controls raise data change event here)
RaisePostBackEvent (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*******@hotmail.com> wrote in message
news:e$**************@TK2MSFTNGP12.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
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...
3
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...
9
by: Robert Galvin | last post by:
Is it possible to tell which control caused a postback?
3
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...
21
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...
1
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...
8
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...
2
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...
4
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.