Print Page | Close Window

IsPostBack

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=20875
Printed Date: 29 March 2026 at 6:49pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: IsPostBack
Posted By: theSCIENTIST
Subject: IsPostBack
Date Posted: 01 August 2006 at 12:57pm
Let me understand this, is it correct to say that, if I use this:
 

If Page.IsPostBack Then
  ... process form POST information ...
Else
  ... theres no form POST information, so run whatever's here ...
End If
 
POST info as in information submited from forms, and I'm assuming only forms submited with POST, not GET.
 
Is my logic correct?


-------------
:: http://www.mylittlehost.com/ - www.mylittlehost.com



Replies:
Posted By: michael
Date Posted: 01 August 2006 at 4:55pm
Well only HTML forms have Post and Get. In asp.net you don't really need that anymore.
In the page load you usually do something like

Private Sub Page_Load
If Not Page.IsPostback THEN
      BindData()
ELSE
      'Fires on Postback so we may not need to do anything
END IF
END SUB

Private Sub BindData
   'Do some SQL Binding or so
END Sub

Private Sub Button_Click()
'Insert a new Row or something
'This is where Post/Get Logic used to be and it actually fires AFTER the postback so if you don't have the postback in pageload, the data would be re-loaded EVERY time.
END Sub


-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: scottage
Date Posted: 04 January 2007 at 9:26am
The purpose of testing for IsPostback is so that code that executes on the initial page load (i.e. pre-filling form fields from a database) doesn't happen when the user changes these values and submits the form so the event handler for the button click gets the users values not the database values as Page_Load will fire before the event handlers code

-------------
http://www.realwebdevelopers.com" rel="nofollow - Developing real world websites



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net