Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi...
I got the idea of what is postback,but dont know why we need it. Almost pageload also loads our page details to server,then what is the use of postback? Plz explain difference of both...
Posted

Hi,
In every page load you do not want to load the data.thats why we use
C#
Ispostback
property.

plese read following posts.

http://delphi.about.com/library/weekly/aa051705a.htm[^]

Detecting Refresh or Postback in ASP.NET[^]
 
Share this answer
 
PostBack is the name given to the process of submitting an ASP.NET page to the server for processing . PostBack is done if certain credentials of the page are to be checked against a database (such as verification of username and password). This is something that a client machine is not able to accomplish and thus these details have to be ‘posted back’ to the server. MSDN describes the page life cycle very clearly in the following link. Please go through it.

http://msdn.microsoft.com/en-us/library/ms178472.aspx[^]

Some other references:

http://www.shoutasp.net/discussions/p344/What-methods-are-fired-during-the-page-load-in-ASP-Net.aspx[^]

http://www.c-sharpcorner.com/uploadfile/2f73dd/what-is-postback-in-Asp-Net/[^]

http://www.evagoras.com/2011/02/10/how-postback-works-in-asp-net/[^]

Regards,
Vani
 
Share this answer
 
hi,

Both PageLoad and PostBack are page life cycle event..

The PageLoad event occurs first and then PostBack.

Post back is a part of page load which can happen only when the page is loaded..


in other words if there is no page load then it means no html elements like buttons
are loaded and since no buttons are loaded so no click event and so no postback can happen.



for eg:

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) //means no postback..page loaded first time
{
//this loop will happen only when the page is loaded for first time..
//here u can put the code or function which you want only once to run
FunctionPageFirstLoad();
}

if (Page.IsPostBack) //its a postback..page has already beenloaded once
{
//this loop will happen only when the page has loaded and then there
//is a click event, may be from button click,
FunctionPageEventClickLoad();
}
}


private void FunctionPageFirstLoad()
{
//this function will be call only once when the page is loaded for the first time.
}
private void FunctionPageEventClickLoad()
{
//this function will be called every time when there is a click event from any button or other element.
}
 
Share this answer
 
according to my side every time when page load occur then post-back value always true
then if you want something is happen in page load and it will not occur after page load then we put these thing on if(!ispostback)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900