What is Ispostback method in ASP.Net? Why do we use that?How can we use pointers in ASP.Net?

Showing Answers 1 - 21 of 21 Answers

umerrasheed

  • Nov 17th, 2007
 

it's a property not a mether. It gets a value indicating whether the page is being loaded in response to a client postback, or if it is being loaded and accessed for the first time.

regards,
Umer Rasheed

  Was this answer useful?  Yes

Deeps2808

  • Apr 18th, 2008
 

Pointers can still be used by enclosing your code under unsafe section.  However instead of pointers we can use referece variables and pointers to function can be achieved by using delegates

  Was this answer useful?  Yes

ravi.faq

  • Mar 30th, 2009
 

Basically Post back is an action performed by a interactive Webpage. When it goes to the server side for a non-client Operation Server again posts it back to the client and hence the name.
Ex:

if(!IsPostBack)

will not allow the page to post back again n again bcoz it reduces the performance.
With Regards
Mr. Ravi More

kirangiet

  • Oct 20th, 2009
 

IsPostBack is a property which returns boolean
value. It checks weather the page is postedback or not.

Note
: Loading a page and Post Back is
two different things.
e.g
Page_Load
{
if(!IsPostBack)
{

SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["TestConStr"].ConnectionString);

SqlDataAdapter da = new SqlDataAdapter("Select * from TestTable", con);

DataSet ds = new DataSet();
da.Fill(ds, "TestTable");

GridView1.DataSource = ds;
GridView1.DataBind();
}
}


The above code will run only first time when
the page is loaded. So within the code block we can write the code which
shouldn't execute on post backs of the page. Still we can view the data in
Gridview because ViewState for GridView is enable [:)].
So we need not to
run the code to populate the GridView every time.  Hence performance gain.

Coming to Pointers
We can use Pointers in .NET with the help of
Unsafe Block.  Just attach the unsafe keyword infront of method declaration
and you are done. Now you can write pointer code inside that method.
e.g.
unsafe public static void Main()
{
//Write code related to pointers.
}

Qais Akhtar

  • Oct 28th, 2011
 

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.

A simple example to illustrate the usage of PostBack is a login page. After the user has typed his username and password, he clicks on the ‘Login’ button. Upon the click, the page is sent to the server to check against the database/XML file to check if the user with supplied details is an authenticated user.

Then there arise certain events ( Listbox Index Changed,RadioButton Checked etc..) in an ASP.NET page upon which a PostBack might be needed. Consider the case in which you have 2 ComboBoxes. Let us say the first ComboBox asks you for the Country you reside in and the second one asks you for the State/Province in that country. Based upon the Country you select, the list of States/Provinces must be shown. Thus, in order to fill the values in the second ComboBox, the selection in the first ComboBox must be known to the server. Thus, as and when an item is selected in the first ComboBox, a PostBack must be done and the appropriate list of items must be filled in the second ComboBox.

To handle these situations, you need to enable the ‘Auto PostBack’ property for those controls whose events are going to trigger some kind of server processing (the case of the first ComboBox in the previous example).

Usage of IsPostBack in ASP.NWT-

IsPostBack is a Boolean property of a page when is set (=true) when a page is first loaded. Thus, the first time that the page loads the IsPostBack flag is false and for subsequent PostBacks, it is true. An important point to be noted here is that each time a PostBack occurs, the entire page including the Page_Load is ‘posted back‘ and executed.

Thus a very common programming practice is that whenever some part of the code is to be executed just the first time a page loads, it is checked against the IsPostBack flag.

If you have not understood the concept clearly, do not worry. Programming examples in subsequent posts will help making this concept clear.

  Was this answer useful?  Yes

Venky Mokka

  • Apr 30th, 2012
 

IsPostBack is a property which returns boolean value. It checks weather the page is postedback or not.

Code
  1.  protected void Page_Load(object sender, EventArgs e)

  2.         {

  3.            

  4.             if (!IsPostBack)

  5.             {

  6.                 bind();

  7.                 FillEmployee();                                        

  8.             }

  9.         }

  Was this answer useful?  Yes

kiran kumar.B

  • May 24th, 2012
 

Why we use postback method in c# .net?

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions