As i didn't understand that what is the usage of "ViewState" ,"PostBack" in Web Application state.I am really confused with these terms.could you please explain with examples?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Niradhip ChakrabortyPosted May 2, 2008, 5:39 AM
Check Out The Following URLs, It help you to understand the concepts of viewstate and postback.
View State:
http://www.w3schools.com/ASPNET/aspnet_viewstate.asp
http://msdn.microsoft.com/en-us/library/ms972976.aspx
PostBack:
http://www.xefteri.com/articles/show.cfm?id=18
http://delphi.about.com/library/weekly/aa051705a.htm
Krishnan LNPosted May 2, 2008, 4:35 AM
Hi,
The Post back is when the page gets rendered from the server when there is an event fired in the server control in a page.
Eg:
If you have a server control(button) called submit. And on click of that you have enable a set of controls. In that case you the write that code inside if(IsPostback) in page_load. This is because when the submit button is clicked, the page is posted to the server back(postback) and in the If(Ispostback) loop you write the code to enable the controls.
Each page and control has a property called view state. If you have the property called 'Enable View State' set to true, when ever the page is loaded on a postback, still the value of the controls are maintened.
For eg, If you have user name and password textboxes, and you enable the view state of user name text box. Now if you enter a user name and password and click on a submit button. The credentials are verified in the server. Now assume that the password was entered wrong by the user.Then you have to show the same login page.When the page is loaded, the username textbox will be filled with the username you entered before, so the user doesnt have to type all the way again. This is the use of viewstate.