Export (0) Print
Expand All

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

Show:
© 2014 Microsoft