IsPostBack in ASP.net

By: Dan Hurwitz and Jesse Liberty Emailed: 1598 times Printed: 2042 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

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.
}
}

Asp Home | All Asp Tutorials | Latest Asp Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(17)


1. View Comment

Nice ,Easy to understand

View Tutorial          By: Jomon at 2009-06-30 00:56:48
2. View Comment

pretty simply explained

View Tutorial          By: nivedita at 2011-06-09 07:32:58
3. View Comment

Very simple, clear visualized and meaning

View Tutorial          By: HIM at 2011-07-21 21:43:58
4. View Comment

simple explanation,.. Nice....

View Tutorial          By: Gopi at 2011-08-19 09:28:47
5. View Comment

So simple..Very easy to understand

View Tutorial          By: G.Tejasree at 2011-11-05 11:51:38
6. View Comment

simply nice.. Thank you.

View Tutorial          By: Anil at 2011-11-30 06:36:23
7. View Comment

Easy to understand

View Tutorial          By: suji at 2012-02-21 08:28:05
8. View Comment

Seriously very nice explanation.... Thank You

View Tutorial          By: Pulkit agrawal at 2012-03-20 10:28:10
9. View Comment

NICE EXPLANATION >>>THANK UUUUUU

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

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


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

Very Nice Explanation.

View Tutorial          By: Anuj Bansal at 2012-08-25 12:23:59
12. View Comment

Great!

View Tutorial          By: justauser at 2012-08-31 13:57:58
13. View Comment

Buenisimo, me ayuda a salir de un problema, cosas sencillas y simples pero siempre necesitamos una guia. Gracias por ayudar.

View Tutorial          By: Emilio, Guatemala at 2012-09-25 15:33:11
14. View Comment

u hav done Nice job..

View Tutorial          By: Rakesh at 2012-10-01 16:00:14
15. View Comment

Nice explaination.. But wats the use of it? Can i restrict my page to reload when i clicked button for the second time?

View Tutorial          By: kavita at 2013-04-04 07:10:14
16. View Comment

nice ....Simple undersstanding..

View Tutorial          By: Anjaneyulu at 2013-06-15 04:43:45
17. View Comment

Easy to understand.good work

View Tutorial          By: Deepika at 2013-12-13 09:33:55

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Dan Hurwitz and Jesse Liberty
DataGrid Control in ASP.net
Directives in ASP.net
Lifecycle of a web form in ASP.net
ASP Versus ASP.NET Events
What is Code-Behind in ASP.net
IsPostBack in ASP.net

More Tutorials in Asp
IsPostBack in ASP.net
What is Code-Behind in ASP.net
ASP Versus ASP.NET Events
Lifecycle of a web form in ASP.net
Directives in ASP.net
DataGrid Control in ASP.net
Advantages of Stored Procedures
Event Driven Programming in ASP.net
Advantages of ASP.NET
What is ASP.NET?
Visual Basic .NET Vs Visual C# - (Differences)
IIS and WAP. Configuring IIS to deliver WML (WAP content)
Getting started with ASP
ActiveX component can't create object: 'CDONTS.NewMail' - ASP

More Latest News
Most Viewed Articles (in Asp )
What is Code-Behind in ASP.net
IsPostBack in ASP.net
Directives in ASP.net
IIS and WAP. Configuring IIS to deliver WML (WAP content)
What is ASP.NET?
Visual Basic .NET Vs Visual C# - (Differences)
Getting started with ASP
Advantages of ASP.NET
Event Driven Programming in ASP.net
DataGrid Control in ASP.net
ActiveX component can't create object: 'CDONTS.NewMail' - ASP
Advantages of Stored Procedures
ASP Versus ASP.NET Events
Lifecycle of a web form in ASP.net
Most Emailed Articles (in Asp)
ActiveX component can't create object: 'CDONTS.NewMail' - ASP
IIS and WAP. Configuring IIS to deliver WML (WAP content)
Getting started with ASP
Advantages of ASP.NET
What is ASP.NET?
Visual Basic .NET Vs Visual C# - (Differences)
Event Driven Programming in ASP.net
Advantages of Stored Procedures
IsPostBack in ASP.net
What is Code-Behind in ASP.net
ASP Versus ASP.NET Events
Lifecycle of a web form in ASP.net
Directives in ASP.net
DataGrid Control in ASP.net