A
antonyliu2002
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.
I did read quite some articles/posts about this, but still could not
clearly understand this terminology.
The MSDN documentation at the following URL says:
http://msdn.microsoft.com/library/d.../frlrfSystemWebUIPageClassIsPostBackTopic.asp
Page.IsPostBack Property
Gets a value indicating whether the page is being loaded in response to
a client postback, or if it is being loaded and accessed for the first
time.
the client.
But what exactly is meant by "being loaded and accessed for the first
time"? How is "for the first time" defined? If I fill up the forms on
a page and submit it to server, is this a postback or no? And when the
server processes the form and returns it to the client, is this the
first time or no? Since the returned page would likely be different
from the original one.
For example, if I have a page called test.aspx. When a user puts the
following URL into the address bar of his/her browser:
http://www.someserver.com/test.aspx
The web server gets this request and compiles the test.aspx page and
sends the resulting HTML back to the client.
Up to this point, OK, there is no problem. This is absolutely the first
time that test.aspx is being accessed or loaded.
Now, suppose that the user enters some user profile information on
test.aspx page and hits the "Submit" button to update his/her profile.
And usually in this case, we enclose our implementation of the
EventHandler of the Submit button with
If Not Page.IsPostBack Then
'Do something
End If
This is exactly where it confuses me (and maybe many others out there).
This "If Not" condition is exactly opposite to my understanding of the
logic. Instead, I think it should be,
If Page.IsPostBack Then
'Do something
End If
Because, after the user fills up his/her profile info and hits the
"Submit" button, isn't this data-submission a postback? So, naturally,
we should state in our code, "if this is a postback, please do this and
this."
But, contrary to my understanding, in order for the web server to
really update the user profile, we are required to state, "if this is
not a postback, please do this and this." Hey, if an updating request
from a client is NOT a postback, then what is a postback?
Any kind guru please clarify postback?
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.
I did read quite some articles/posts about this, but still could not
clearly understand this terminology.
The MSDN documentation at the following URL says:
http://msdn.microsoft.com/library/d.../frlrfSystemWebUIPageClassIsPostBackTopic.asp
Page.IsPostBack Property
Gets a value indicating whether the page is being loaded in response to
a client postback, or if it is being loaded and accessed for the first
time.
some bits of information has been transmitted to the Web server fromFrom my understanding, there is no doubt that "postback" means that
the client.
But what exactly is meant by "being loaded and accessed for the first
time"? How is "for the first time" defined? If I fill up the forms on
a page and submit it to server, is this a postback or no? And when the
server processes the form and returns it to the client, is this the
first time or no? Since the returned page would likely be different
from the original one.
For example, if I have a page called test.aspx. When a user puts the
following URL into the address bar of his/her browser:
http://www.someserver.com/test.aspx
The web server gets this request and compiles the test.aspx page and
sends the resulting HTML back to the client.
Up to this point, OK, there is no problem. This is absolutely the first
time that test.aspx is being accessed or loaded.
Now, suppose that the user enters some user profile information on
test.aspx page and hits the "Submit" button to update his/her profile.
And usually in this case, we enclose our implementation of the
EventHandler of the Submit button with
If Not Page.IsPostBack Then
'Do something
End If
This is exactly where it confuses me (and maybe many others out there).
This "If Not" condition is exactly opposite to my understanding of the
logic. Instead, I think it should be,
If Page.IsPostBack Then
'Do something
End If
Because, after the user fills up his/her profile info and hits the
"Submit" button, isn't this data-submission a postback? So, naturally,
we should state in our code, "if this is a postback, please do this and
this."
But, contrary to my understanding, in order for the web server to
really update the user profile, we are required to state, "if this is
not a postback, please do this and this." Hey, if an updating request
from a client is NOT a postback, then what is a postback?
Any kind guru please clarify postback?