Export (0) Print
Expand All
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

Not applicable.

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.

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

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

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

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.