IsPostBack in

By: Dan Hurwitz and Jesse Liberty  

The page exposes the IsPostBack property. This is a read-only Boolean property that indicates if the page or control is being loaded for the first time, or if it is being loaded in response to a client postback. Many expensive operations (such as getting data from a database or populating ListItems) must be performed only the first time the page or control is loaded. If the page is posted to the server and then reloaded, there is no need to repeat the operation. By testing the value of IsPostBack, you can skip the expensive operation, as in the code snippets in Example 1 and Example 2.

Example 1. Testing for IsPostBack in VB.NET
sub Page_Load(ByVal Sender as Object, _
ByVal e as EventArgs)
if not IsPostBack then
' Do the expensive operations only the 
' first time the page is loaded.
end if
end sub
Example 2. Testing for IsPostBack in C#
void Page_Load(Object sender, EventArgs e)
if (! IsPostBack)
// Do the expensive operations only the 
// first time the page is loaded.

Archived Comments

1. Larryhaw
View Tutorial          By: Larryhaw at 2017-07-25 01:03:24

2. Easy to understand.good work
View Tutorial          By: Deepika at 2013-12-13 09:33:55

3. nice ....Simple undersstanding..
View Tutorial          By: Anjaneyulu at 2013-06-15 04:43:45

4. Hi,

This is a very informative article. Thanks for sharing your knowledge. I have fin

View Tutorial          By: Andrew Deniel at 2013-05-29 11:42:43

5. Nice explaination.. But wats the use of it? Can i restrict my page to reload when i clicked button f
View Tutorial          By: kavita at 2013-04-04 07:10:14

6. u hav done Nice job..
View Tutorial          By: Rakesh at 2012-10-01 16:00:14

7. Buenisimo, me ayuda a salir de un problema, cosas sencillas y simples pero siempre necesitamos una g
View Tutorial          By: Emilio, Guatemala at 2012-09-25 15:33:11

8. Great!
View Tutorial          By: justauser at 2012-08-31 13:57:58

9. Very Nice Explanation.
View Tutorial          By: Anuj Bansal at 2012-08-25 12:23:59

10. It helped me, also. Thank You :).
View Tutorial          By: Roska at 2012-07-22 20:19:30

11. got it in one glance ...
thank u

View Tutorial          By: pravallika at 2012-07-21 20:05:59

12. good one in a very simple way...
View Tutorial          By: Harshita Sharma at 2012-07-15 13:28:46

13. Thank You So Much . .. .. .
Very Nice Explanation.

View Tutorial          By: salman at 2012-07-05 13:22:11

View Tutorial          By: PraVeen at 2012-07-05 10:12:25

15. I thought it is big concept but the example which you have given makes me to understand so simple .
View Tutorial          By: Nambu karthy.R at 2012-06-27 13:18:20

16. nice artical, very easy to understand.
View Tutorial          By: Kamlesh Tiwari at 2012-06-07 12:23:32

17. Easy to understand,thank u
View Tutorial          By: Soung Pann Wai at 2012-04-24 04:42:44

18. Seriously very nice explanation.... Thank You
View Tutorial          By: Pulkit agrawal at 2012-03-20 10:28:10

19. Easy to understand
View Tutorial          By: suji at 2012-02-21 08:28:05

20. simply nice.. Thank you.
View Tutorial          By: Anil at 2011-11-30 06:36:23

21. So simple..Very easy to understand
View Tutorial          By: G.Tejasree at 2011-11-05 11:51:38

22. Good..neatly explained
View Tutorial          By: jithu at 2011-10-17 11:15:24

23. very simple
View Tutorial          By: vishu at 2011-10-07 06:38:49

24. Super
View Tutorial          By: Sathish godalatty at 2011-09-19 10:11:13

25. simple explanation,.. Nice....
View Tutorial          By: Gopi at 2011-08-19 09:28:47

26. simple explanation.. Nice...
View Tutorial          By: Gopi at 2011-08-19 09:24:30

27. Very simple, clear visualized and meaning
View Tutorial          By: HIM at 2011-07-21 21:43:58

28. pretty simply explained
View Tutorial          By: nivedita at 2011-06-09 07:32:58

29. Very Good explanation . Thanks.
View Tutorial          By: Dipti at 2010-09-15 21:57:09

30. Nice ,Easy to understand
View Tutorial          By: Jomon at 2009-06-30 00:56:48

Most Viewed Articles (in Asp )

Latest Articles (in Asp)

Comment on this tutorial