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.

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s