Page Load Vs Postback Vs page Refresh(F5) and ViewState in Asp.Net

PageLoad:- When a page loads very first time that is Page Load, all the controls will bind to their values. It’s a Http GET request.

Postback:- When a user clicks on a server-side control then page send back to server and after processing comes back to browser and loads again. It’s Http POST request.

Page Refresh(F5):- Whatever was your last action, it will repeat that. Suppose last action was page load then it will repeat it and does again page load. If last time was postback the F5 will to one more postback. It can be a HTTP POST or GET request.

ViewState:- In case of PageLoad ViewState will have it’s initial value, that means if it is not defined then NULL, else whatever value you have defined it’ll keep it. But in case of Postback, it maintains last value. Suppose value of ViewSatate is 10 now and on every postback you have write code to increment this value then if again postback happens then value of ViewState would be 11. If now user press F5 the again it’ll be postback and current value of ViewState would be 12. But if user hits Enter key, that means new pageload request, so ViewState will lost its value and reset to initial value of it, means if there is no ViewState initially then NULL else reset to initial value.



2 thoughts on “Page Load Vs Postback Vs page Refresh(F5) and ViewState in Asp.Net

    1. I’m not sure I understood your question correctly but the thing is ViewState is to hold the data on postback once page is refreshed it’ll be null. So, there is nothing like default try to fetch stuff. It’s your code that does it. if you have written code to read it back then it’ll read otherwise nothing will happen. If this explanation is not relevant then please write back to me with some more details and I’ll try to answer your.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s