.NET Framework Class Library
PageIsPostBack Property

Gets a value that indicates whether the page is being rendered for the first time or is being loaded in response to a postback.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)
Syntax
<[%$TOPIC/5zabsw0t_en-us_VS_110_1_0_0_0_0%](False)> _
Public ReadOnly Property IsPostBack As [%$TOPIC/5zabsw0t_en-us_VS_110_1_0_0_0_1%]
[[%$TOPIC/5zabsw0t_en-us_VS_110_1_0_1_0_0%](false)]
public [%$TOPIC/5zabsw0t_en-us_VS_110_1_0_1_0_1%] IsPostBack { get; }
[[%$TOPIC/5zabsw0t_en-us_VS_110_1_0_2_0_0%](false)]
public:
property [%$TOPIC/5zabsw0t_en-us_VS_110_1_0_2_0_1%] IsPostBack {
	[%$TOPIC/5zabsw0t_en-us_VS_110_1_0_2_0_2%] get ();
}
[<[%$TOPIC/5zabsw0t_en-us_VS_110_1_0_3_0_0%](false)>]
member IsPostBack : [%$TOPIC/5zabsw0t_en-us_VS_110_1_0_3_0_1%] with get

Property Value

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

For an explanation of the difference between postbacks and callbacks, see Implementing Client Callbacks Programmatically Without Postbacks in ASP.NET Web Pages.

Examples

The following example shows how to test the value of the IsPostBack property when the page is loaded in order to determine whether the page is being rendered for the first time or is responding to a postback. If the page is being rendered for the first time, the code calls the PageValidate method.

The page markup (not shown) contains RequiredFieldValidator controls that display asterisks if no entry is made for a required input field. Calling PageValidate causes the asterisks to be displayed immediately when the page is rendered, instead of waiting until the user clicks the Submit button. After a postback, you do not have to call PageValidate, because that method is called as part of the Page life cycle.

Sub Page_Load
    If Not IsPostBack
        ' Validate initially to force the asterisks
        ' to appear before the first roundtrip.
        Validate()
    End If
End Sub
private void Page_Load()
{
    if (!IsPostBack)
    {
        // Validate initially to force asterisks
        // to appear before the first roundtrip.
        Validate();
    }
}
Version Information

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0
Platforms

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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