By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,612 Members | 1,632 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,612 IT Pros & Developers. It's quick & easy.

difference between refreshing a page, postback and viewstate

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.