IPostBackDataHandler Interface
Defines methods that ASP.NET server controls must implement to automatically load postback data.
Assembly: System.Web (in System.Web.dll)
The IPostBackDataHandler type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | LoadPostData | When implemented by a class, processes postback data for an ASP.NET server control. |
![]() | RaisePostDataChangedEvent | When implemented by a class, signals the server control to notify the ASP.NET application that the state of the control has changed. |
You must implement the IPostBackDataHandler interface when creating a server control that needs to examine form data that is posted back to the server by the client. The contract that this interface defines allows a server control to determine whether its state should be altered as a result of the postback, and to raise the appropriate events. For more information, see Server Event Handling in ASP.NET Web Pages.
The following code example demonstrates a custom text box server control that implements the IPostBackDataHandler interface. The Text property is changed as a result of the postback, and the server control raises a TextChanged event after postback data has been loaded.
Imports System Imports System.Web Imports System.Web.UI Imports System.Collections Imports System.Collections.Specialized Namespace CustomWebFormsControls <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> Public Class MyTextBox Inherits Control Implements IPostBackDataHandler Public Property Text() As String Get Return CType(Me.ViewState("Text"), String) End Get Set Me.ViewState("Text") = value End Set End Property Public Event TextChanged As EventHandler Public Overridable Shadows Function LoadPostData( _ postDataKey As String, _ postCollection As System.Collections.Specialized.NameValueCollection) _ As Boolean Implements IPostBackDataHandler.LoadPostData Dim presentValue As String = Text Dim postedValue As String = postCollection(postDataKey) If presentValue Is Nothing Or Not presentValue.Equals(postedValue) Then Text = postedValue Return True End If Return False End Function Public Overridable Shadows Sub RaisePostDataChangedEvent() _ Implements IPostBackDataHandler.RaisePostDataChangedEvent OnTextChanged(EventArgs.Empty) End Sub Protected Overridable Sub OnTextChanged(e As EventArgs) RaiseEvent TextChanged(Me, e) End Sub Protected Overrides Sub Render(output As HtmlTextWriter) output.Write("<INPUT type= text name = " & Me.UniqueID & _ " value = " & Me.Text & " >") End Sub End Class End Namespace
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
