what is the difference between postback data and view state data
Asked Answered
F

5

7

I am trying to understand different events in a Asp.net page life cycle. I came across to this link. It has two stages Load view state and Load postback data. I used to thought that these both means the same thing. But this article says, that postback data is not viewstate data. I don't understand this. If anyone can have a look.

Fantoccini answered 21/4, 2010 at 13:50 Comment(0)
D
16

ViewState data is data that ASP.NET encoded end sent to the client in the _ViewState hidden field. It's basically the page as it was when it was sent to the client.

PostBack data is data that the user submits.

For example suppose you have a textbox on a page defined like so:

<asp:TextBox id="TextBox1" runat="server" text="Some Text" />

You type in My user input into the textbox and submit the form. Some Text would be ViewState data and My user input would be the PostBack data.

EDIT And in case you would like to learn more about ViewState, there's an excellent article here: Truly Understanding Viewstate.

Disgorge answered 21/4, 2010 at 13:58 Comment(2)
+1 for giving example. So it means if I call a page first time, it would have viewstate.Fantoccini
@vaibhav: Unless you turn it off, yes. When you submit the page, it will have both ViewState and PostBack data as Mikael Svenson mentioned.Disgorge
H
11

The viewstate was the current state when the page was rendered to the browser.

The post back data is what the user changed and resubmitted.

Homeostasis answered 21/4, 2010 at 13:55 Comment(1)
And the viewstate is sent back as part of the postback data, but handled specially to rebuild the state of your controls.Mezoff
W
1

view state means storing the contents of fields temporarorily where as postback means submitting the form itself .cross postback is the redirecting from one form to another form.

Windswept answered 5/4, 2011 at 2:26 Comment(0)
C
0

This one is the msdn article. It sort of explains it so nicely using images.

Circumvallate answered 21/4, 2010 at 13:58 Comment(1)
@Anil This is the same article, I am talking about.Fantoccini
M
-1

viewstate is when the page is first displayed in the browser (page load) Post back data is when the user has made changes and submitted the form;

Maneater answered 21/4, 2010 at 16:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.