User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,564 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,522 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 5223 | Replies: 5 | Solved
Reply
Join Date: Oct 2007
Posts: 10
Reputation: divya.padukone is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
divya.padukone divya.padukone is offline Offline
Newbie Poster

Page.IsPostBack

  #1  
Oct 23rd, 2007
wanted to know the difference between Page.IsPostBack and Not page.IsPostBack.
what is the purpose of using these? where it is being used?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Page.IsPostBack

  #2  
Oct 23rd, 2007
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..
Reply With Quote  
Join Date: Aug 2005
Location: Ohio
Posts: 204
Reputation: plazmo is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 16
plazmo's Avatar
plazmo plazmo is offline Offline
Posting Whiz in Training

Re: Page.IsPostBack

  #3  
Oct 23rd, 2007
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.
Reply With Quote  
Join Date: Oct 2007
Posts: 10
Reputation: divya.padukone is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
divya.padukone divya.padukone is offline Offline
Newbie Poster

Re: Page.IsPostBack

  #4  
Oct 24th, 2007
Thanx alot for the help...
Reply With Quote  
Join Date: Oct 2007
Posts: 10
Reputation: divya.padukone is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
divya.padukone divya.padukone is offline Offline
Newbie Poster

Re: Page.IsPostBack

  #5  
Oct 24th, 2007
Thank you...
Reply With Quote  
Join Date: Sep 2007
Posts: 1,058
Reputation: SheSaidImaPregy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 61
SheSaidImaPregy SheSaidImaPregy is offline Offline
Veteran Poster

Re: Page.IsPostBack

  #6  
Oct 24th, 2007
no problem
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 5:46 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC