473,396 Members | 2,076 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,396 software developers and data experts.

difference between refreshing a page, postback and viewstate

Dan
Hi,

i'm not sure to understand the difference between refreshing the pagina by
clicking on 'refresh' in the browser and a postback.
What i think it is:
Suppose a page with a form containing a textbox and a dropdowlist: and a
button to start something n code-behind:
a refresh doesn't send any value back to the server but with a postback, the
values are sent?
But then, which role does Viewstate play in the postback proces?

Thanks for explaining me.
Dan
May 24 '07 #1
4 5034
Dan,
A "Refresh" simply calls the last request made for a page. So, if
you just browsed to a page then hit refresh, it simply asks for that page
again.

A Postback is essentially an action on the page that sends
information back to the server. This is done using what is known as the Post
method (there is also a Get method and that's what the variables in the
querystring really are, get fields). So any activity that sends the page
back to the server is a post. Normally this is done by clicking on a button,
link button, image button, or through client-side javascript.

Now, when you do a "Refresh" after some activity that caused a post,
such as pushing a submit button, the page will "Refresh" the last activity.
So, if you push the submit button, then hit refresh it will send all the
post information again.

ViewState is essentially a client-side state information store,
giving you a way to save values and have them held in the page across many
postbacks. This is required since the web is a stateless environment and the
web server doesn't stay connected to the client browser after the page has
been completely fetched. You can save or edit viewstate variables, and also
get their information. One of the key things to remember is the viewstate
can only really be changed when you post back to the server. Let's say you
have a counter viewstate property. You set it to 1 when the user first
visits the page. You would expect it to increment when you hit the refresh
button but it doesn't. The reason is all you're doing is refreshing the
first request and setting the viewstate to one again. When you hit a button
and do a postback you'll be in a position where that viewstate variable
already exists and is set to one so now it can be incremented to 2.

Another thing to learn about the viewstate is it's not available in all
page events. The viewstate gets loaded a little later in the page lifecycle
so that it wouldn't be available in the oninit event, but is available by
the time the pageload event happens.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Dan" <da*@eee.eewrote in message
news:u1****************@TK2MSFTNGP05.phx.gbl...
Hi,

i'm not sure to understand the difference between refreshing the pagina by
clicking on 'refresh' in the browser and a postback.
What i think it is:
Suppose a page with a form containing a textbox and a dropdowlist: and a
button to start something n code-behind:
a refresh doesn't send any value back to the server but with a postback,
the values are sent?
But then, which role does Viewstate play in the postback proces?

Thanks for explaining me.
Dan

May 24 '07 #2
Dan
Hi Mark, thanks for your explanation.
One more thing: what's the default value (true or false)?
My web.config doesn't contain EnableViewState, nor any page ..

"Mark Fitzpatrick" <ma******@fitzme.comschreef in bericht
news:O9**************@TK2MSFTNGP05.phx.gbl...
Dan,
A "Refresh" simply calls the last request made for a page. So, if
you just browsed to a page then hit refresh, it simply asks for that page
again.

A Postback is essentially an action on the page that sends
information back to the server. This is done using what is known as the
Post method (there is also a Get method and that's what the variables in
the querystring really are, get fields). So any activity that sends the
page back to the server is a post. Normally this is done by clicking on a
button, link button, image button, or through client-side javascript.

Now, when you do a "Refresh" after some activity that caused a
post, such as pushing a submit button, the page will "Refresh" the last
activity. So, if you push the submit button, then hit refresh it will send
all the post information again.

ViewState is essentially a client-side state information store,
giving you a way to save values and have them held in the page across many
postbacks. This is required since the web is a stateless environment and
the web server doesn't stay connected to the client browser after the page
has been completely fetched. You can save or edit viewstate variables, and
also get their information. One of the key things to remember is the
viewstate can only really be changed when you post back to the server.
Let's say you have a counter viewstate property. You set it to 1 when the
user first visits the page. You would expect it to increment when you hit
the refresh button but it doesn't. The reason is all you're doing is
refreshing the first request and setting the viewstate to one again. When
you hit a button and do a postback you'll be in a position where that
viewstate variable already exists and is set to one so now it can be
incremented to 2.

Another thing to learn about the viewstate is it's not available in all
page events. The viewstate gets loaded a little later in the page
lifecycle so that it wouldn't be available in the oninit event, but is
available by the time the pageload event happens.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Dan" <da*@eee.eewrote in message
news:u1****************@TK2MSFTNGP05.phx.gbl...
>Hi,

i'm not sure to understand the difference between refreshing the pagina
by clicking on 'refresh' in the browser and a postback.
What i think it is:
Suppose a page with a form containing a textbox and a dropdowlist: and a
button to start something n code-behind:
a refresh doesn't send any value back to the server but with a postback,
the values are sent?
But then, which role does Viewstate play in the postback proces?

Thanks for explaining me.
Dan


May 24 '07 #3
"Enabled"
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Dan" wrote:
Hi Mark, thanks for your explanation.
One more thing: what's the default value (true or false)?
My web.config doesn't contain EnableViewState, nor any page ..

"Mark Fitzpatrick" <ma******@fitzme.comschreef in bericht
news:O9**************@TK2MSFTNGP05.phx.gbl...
Dan,
A "Refresh" simply calls the last request made for a page. So, if
you just browsed to a page then hit refresh, it simply asks for that page
again.

A Postback is essentially an action on the page that sends
information back to the server. This is done using what is known as the
Post method (there is also a Get method and that's what the variables in
the querystring really are, get fields). So any activity that sends the
page back to the server is a post. Normally this is done by clicking on a
button, link button, image button, or through client-side javascript.

Now, when you do a "Refresh" after some activity that caused a
post, such as pushing a submit button, the page will "Refresh" the last
activity. So, if you push the submit button, then hit refresh it will send
all the post information again.

ViewState is essentially a client-side state information store,
giving you a way to save values and have them held in the page across many
postbacks. This is required since the web is a stateless environment and
the web server doesn't stay connected to the client browser after the page
has been completely fetched. You can save or edit viewstate variables, and
also get their information. One of the key things to remember is the
viewstate can only really be changed when you post back to the server.
Let's say you have a counter viewstate property. You set it to 1 when the
user first visits the page. You would expect it to increment when you hit
the refresh button but it doesn't. The reason is all you're doing is
refreshing the first request and setting the viewstate to one again. When
you hit a button and do a postback you'll be in a position where that
viewstate variable already exists and is set to one so now it can be
incremented to 2.

Another thing to learn about the viewstate is it's not available in all
page events. The viewstate gets loaded a little later in the page
lifecycle so that it wouldn't be available in the oninit event, but is
available by the time the pageload event happens.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Dan" <da*@eee.eewrote in message
news:u1****************@TK2MSFTNGP05.phx.gbl...
Hi,

i'm not sure to understand the difference between refreshing the pagina
by clicking on 'refresh' in the browser and a postback.
What i think it is:
Suppose a page with a form containing a textbox and a dropdowlist: and a
button to start something n code-behind:
a refresh doesn't send any value back to the server but with a postback,
the values are sent?
But then, which role does Viewstate play in the postback proces?

Thanks for explaining me.
Dan


May 24 '07 #4
Dan
Ok, thanks

"Peter Bromberg [C# MVP]" <pb*******@yahoo.yabbadabbadoo.comschreef in
bericht news:37**********************************@microsof t.com...
"Enabled"
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Dan" wrote:
>Hi Mark, thanks for your explanation.
One more thing: what's the default value (true or false)?
My web.config doesn't contain EnableViewState, nor any page ..

"Mark Fitzpatrick" <ma******@fitzme.comschreef in bericht
news:O9**************@TK2MSFTNGP05.phx.gbl...
Dan,
A "Refresh" simply calls the last request made for a page. So,
if
you just browsed to a page then hit refresh, it simply asks for that
page
again.

A Postback is essentially an action on the page that sends
information back to the server. This is done using what is known as the
Post method (there is also a Get method and that's what the variables
in
the querystring really are, get fields). So any activity that sends the
page back to the server is a post. Normally this is done by clicking on
a
button, link button, image button, or through client-side javascript.

Now, when you do a "Refresh" after some activity that caused a
post, such as pushing a submit button, the page will "Refresh" the last
activity. So, if you push the submit button, then hit refresh it will
send
all the post information again.

ViewState is essentially a client-side state information store,
giving you a way to save values and have them held in the page across
many
postbacks. This is required since the web is a stateless environment
and
the web server doesn't stay connected to the client browser after the
page
has been completely fetched. You can save or edit viewstate variables,
and
also get their information. One of the key things to remember is the
viewstate can only really be changed when you post back to the server.
Let's say you have a counter viewstate property. You set it to 1 when
the
user first visits the page. You would expect it to increment when you
hit
the refresh button but it doesn't. The reason is all you're doing is
refreshing the first request and setting the viewstate to one again.
When
you hit a button and do a postback you'll be in a position where that
viewstate variable already exists and is set to one so now it can be
incremented to 2.

Another thing to learn about the viewstate is it's not available in
all
page events. The viewstate gets loaded a little later in the page
lifecycle so that it wouldn't be available in the oninit event, but is
available by the time the pageload event happens.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Dan" <da*@eee.eewrote in message
news:u1****************@TK2MSFTNGP05.phx.gbl...
Hi,

i'm not sure to understand the difference between refreshing the
pagina
by clicking on 'refresh' in the browser and a postback.
What i think it is:
Suppose a page with a form containing a textbox and a dropdowlist: and
a
button to start something n code-behind:
a refresh doesn't send any value back to the server but with a
postback,
the values are sent?
But then, which role does Viewstate play in the postback proces?

Thanks for explaining me.
Dan



May 24 '07 #5

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

Similar topics

4
by: Nathan Sokalski | last post by:
When form data is submitted to an ASP page using the POST method, it is not visible in the URL, but it is still resubmitted if the user clicks the Refresh button. This can cause statistical data to...
4
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than...
4
by: Marty U. | last post by:
How can you declare an object that is global to a page even on postbacks? I currently have something like this MyObject m; throughout the page on the initial load everything works fine but...
0
by: seven | last post by:
I have a base page with an HTMLForm object (added to the base page control heiarchy during Init). In the design of pages derived from this base page, I can choose to create controls and add them...
1
by: pv_kannan | last post by:
One of our dev team members is having a strange problem with a datagrid... We are not seeing a datagrid's data getting refreshed after a new row is entered in a popup window inspite of resetting...
1
by: Petr SIMUNEK | last post by:
I have 3 buttons on the page. (Created dynamicaly inside For- next loop and hooked up to click event.) When different button is clicked i would like to save a different value to viewstate. In the...
9
by: Alexander van Doormalen | last post by:
I have a situation that user controls are dynamically loaded within a page. To know which control to 're-add' to the page I saved the control path in the ViewState. This Control is added using...
3
by: Angel Of Death | last post by:
A postback and a callback. Does a callback always avoid a page being re-sent in it's entirety back to the client and does a post-back always force a browser to reload an entire page? Is this my...
3
by: Nathan Sokalski | last post by:
I am recieving the following error on the second postback of a page I have written: The state information is invalid for this page and might be corrupted Stack Trace: ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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
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
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...
0
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
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...

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.