Subscribe to Subscribers
Talk to Webmaster Tony John

Online Members

Pawan Awasthi
More...


Resources » Code Snippets » ASP.NET WebForms

How to use IsPostBack property in ASP.NET pages to determine if the page is posted back


Posted Date:     Category: ASP.NET WebForms    
Author: Member Level: Gold    Points: 5


This article demonstrates how you can use the Page.IsPostback proeprty to determine of the page is submitted or it is first time loading.



 


In ASP.Net, the Page Load is event is fired every time a page is loaded. This is true even if the page is loaded as part of a submit button click. You may need to identify if the page load event is called as part of a page submit or if it is a fresh page rendering. Because, in case of page submit, you may want to skip several task like populating the data again etc.

The IsPostBack property can be used to determine if the page is submitted to itself. When a form is posted (submitted) back to the same page that contains it, it's called a post back. ASP.NET provides a property called IsPostBack that is TRUE when the page is being loaded as a result of a post back, and is FALSE otherwise.

We can check the value of this property and based on the value, we can populate the controls in the page. If the property is TRUE, that means it is a postback (submit) and no need to populate all the values again.

Sample

Sub Page_Load
IF Not IsPostBack THEN
' Need to do load the grid only if it is first time load.
grdtest.DataSource = Session("dS")
grdtest.DataBind()
END IF
End Sub





Did you like this resource? Share it with your friends and show your love!


Responses to "How to use IsPostBack property in ASP.NET pages to determine if the page is posted back "
Author: Ahmad M. Alkilani    27 Apr 2004Member Level: Bronze   Points : 0
Thank you for writting this article. You explained the topic well.


Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Previous Resource: How to disable right click in internet explorer
    Return to Resources
    Post New Resource
    Category: ASP.NET WebForms


    Post resources and earn money!
     
    Popular Tags   Tag posting guidelines   Search Tags  
    How to use IsPostBack property in ASP.NET pages  .  Determine if the page is posted back using PostBack  .  Use PostBack property to determine if the page is posted back  .  Determine if the page is posted back in ASP.NET  .  Using PostBack property  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.