Tuesday, January 17, 2012

how to use Ispostback property in asp.net

It is one of the properties of Page Object.Page object is a reference of web page class object.This will be created by implicitly.The client request to web server [web page] can e classifieds two types
1.Ordinary Request
2.Post Back Request
Ordinary Request:When user is typing URL under address bar of browser ,to make a request,It is called Ordinary request
Post back Request:When user is interfacing with a control to make a request to web server.It is called Post Back request

Ispostback Properties
|
|
True->when the request is post back request
False->when the request is Ordinary request

This properties is useful to execute certain logic with in the page load event towards ordinary Ordinary Request
Default.aspx:
<button id="myButton" onclick="Btn_Click" runat="server" text="Click Me" type="submit"></button>
Example:
Protected void Page_Load(Object sender, EventArgs e)
 {
  if(page.Ispostback==false)
    {
      Response.Write("Ordinary Request);
      else
      Response.Write("Post Back Request); 
    }
  }
public void Btn_Click(Object sender,
                           EventArgs e)
{
 //logic
}
The post back can perform when click on the button .

3 comments:

Anonymous said...

simple and good explanation. Thank you!!!

phurba said...

Thanks !

phurba said...

Thanks !

Bel