UserControl.IsPostBack Property
Gets a value indicating whether the user control 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 user control is being loaded in response to a client postback; otherwise, false.
Example
[Visual Basic, C#] The following example adds two key value pairs to the application state associated with a user control if the user control's IsPostBack property returns false. When this condition is met, the code uses the Add method, through the user control's Application property, to add the keys and their values.
[Visual Basic] If (Not myControl.IsPostBack) Then ' Add new objects to the HttpApplicationState. ' These will be maintained as long as the as the application is active. myControl.Application.Add("Author","Shafeeque") myControl.Application.Add("Date",new DateTime(2001,6,21)) [C#] if (!myControl.IsPostBack) { // Add new objects to the HttpApplicationState. // These will be maintained as long as the application is active. myControl.Application.Add("Author","Shafeeque"); myControl.Application.Add("Date",new DateTime(2001,6,21));
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
UserControl Class | UserControl Members | System.Web.UI Namespace | IsPostBack