Page.IsPostBack Property Home
This page is specific to:.NET Framework Version:1.12.03.03.54.0
.NET Framework Class Library
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.

[Visual Basic]
Public ReadOnly Property IsPostBack As Boolean
[C#]
public bool IsPostBack {get;}
[C++]
public: __property bool get_IsPostBack();
[JScript]
public function get IsPostBack() : Boolean;

Property Value

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

Example

[Visual Basic, C#, JScript] The following 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.

[Visual Basic] 
Sub Page_Load
    If Not IsPostBack
        ' Validate initially to force the asterisks
' to appear before the first roundtrip.
        Validate()
    End If
End Sub

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

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

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Page Class | Page Members | System.Web.UI Namespace

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View