954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Page.IsPostBack

wanted to know the difference between Page.IsPostBack and Not page.IsPostBack.
what is the purpose of using these? where it is being used?

divya.padukone
Newbie Poster
10 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

Page.IsPostBack is for forms that are runat="server". It is mostly used for same page validation, same page operations, ... anything really same page!

It is also used to help keep bandwidth and rendering times down.

The main reason why people use IsPostBack is to stop taping the databases everytime a request is made. If you are on your default page and just do work via that page, you can use the if Not page.ispostback then statements to populate information. When pages are posted back to the sever and then rendered back to the client, they don't have the need to repopulate the information since it was just populated. It is all kept in the viewstate and read back without using precious resources on the server.

It's a very good and handy tool to know, and very easy to know as well! Any information that is not variable dependant should be only posted when the user first shows the page.

For another example, let's say you are using menus that pull information from the database, articles that are previewed on a side bar for users with a link to the full article, and a search function that posts results that can be ordered by date, name, etc. Now, with the IsPostBack functionality, you can add the statement to all information that does not change when a request is made on the same page. You can add the "If Not Page.IsPostBack Then" for the menus and articles since the information does not change in anyway when a user clicked to have the search results ordered by name! This means that you do not have to tap the database three times, but only once! The information about the menus and articles are held in the viewstate so you don't have to repopulate them.

Then for the "If Page.IsPostBack Then" statement, you can use for registration purposes for your site, post comments, etc. all by the Page.IsPostBack function. No code in the "If Page.IsPostBack Then" statement is fired when the page is requested by the client for the first time; And vice-versa, the "If Not Page.IsPostBack Then" function is only fired when the page is called for the first time, then uses viewstate to fill in the areas it is required to for every postback after that.

Hope this helps..

SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68
 

Page.IsPostBack Is used to check if the user posted back to the page. Meaning they clicked a button or changed a field in the form that causes it to post back to itself.
Putting Not usually is used to check the initial load of the page.
You only need to fill databound fields on the initial load, so you put all your databinding code in the Not page.IsPostBack. The values are saved in the viewstate and can only be read by the form if it gets posted back to itself.
So, if it is a postback dont do databinding if its not a postback do databinding.

plazmo
Posting Whiz in Training
207 posts since Aug 2005
Reputation Points: 23
Solved Threads: 16
 

Thanx alot for the help...

divya.padukone
Newbie Poster
10 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

Thank you...

divya.padukone
Newbie Poster
10 posts since Oct 2007
Reputation Points: 10
Solved Threads: 0
 

no problem

SheSaidImaPregy
Veteran Poster
1,080 posts since Sep 2007
Reputation Points: 43
Solved Threads: 68
 

The given information about if (!Page.IsPostBack) is really good.

!!!!!!! Thanks a lot !!!!!!!!!

BinnY197
Newbie Poster
1 post since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

thank u

yogeswararao
Newbie Poster
1 post since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

Well page, IsPostBack is gets a value that indicates whether the page is being rendered for the first time or is being loaded in response to a postback, if you are using the datagird, then the not postback means it will not postback the page that means it will not have any changes in the data-grid, and the page. IspostBack means the page is postback when any changes made in datagrid.

Barbaradavid
Newbie Poster
2 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

thanks very much for the information. as it was very useful at the starting instance for anyone who is new to page.ispostback. :)

jay_gandhi
Newbie Poster
1 post since Sep 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You