System.Web.UI Namespace Page Class
Returns 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.
Script |
[ bool variable = ] Page.IsPostBack |
This property returns only a boolean value: true if the page is being loaded in response to a client postback; otherwise, false. Default value is false.
Use the IsPostBack property to test either of two states:
- if the page is being loaded and accessed for the first time ( IsPostBack returns false ), or
- if the page is being loaded in response to a client postback ( IsPostBack returns true ).
This property is typically used within a Page_Load event handler to conditionally execute one or more embedded statements, depending on the IsPostBack state when the page is loaded.
The following example evaluates IsPostBack on page load, and runs the embedded statements only if IsPostBack is not true, indicating the page is being accessed for the first time.
protected void Page_Load ( Object Src, EventArgs E ) {
if ( !IsPostBack ) {
string query = "SELECT DISTINCT Type FROM Products";
mySelect.DataSource = fetchData ( query, "gear" );
mySelect.DataBind ( );
}
}
Show me
Page Members