7 out of 26 rated this helpful - Rate this topic

Page.IsPostBack Property

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.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

public bool IsPostBack { get; }
/** @property */
public boolean get_IsPostBack ()

public function get IsPostBack () : boolean

Property Value

true if the page is being loaded in response to a client postback; otherwise, false.

The following code example tests the value of the IsPostBack property to conditionally call the Page.Validate method for all validation server controls when the Page is loaded.

void Page_Load() {
    if (!IsPostBack) {
        // Validate initially to force asterisks
// to appear before the first roundtrip.
        Validate();
    }
}

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
IsPostBack and control population

When you dynamically populate databound controls (for example DropDownList) with data on Page_Load, you should usually check the IsPostBack variable and make sure you populate the data on the first page load instead of everytime the postback occurs.

Otherwise the data gets reloaded on every postback and some strange behavior can occur when you try to use the data.