This documentation is archived and is not being maintained.

IPostBackDataHandler.LoadPostData Method

When implemented by a class, processes post back data for an ASP.NET server control.

[Visual Basic]
Function LoadPostData( _
   ByVal postDataKey As String, _
   ByVal postCollection As NameValueCollection _
) As Boolean
[C#]
bool LoadPostData(
   string postDataKey,
 NameValueCollection postCollection
);
[C++]
bool LoadPostData(
   String* postDataKey,
 NameValueCollection* postCollection
);
[JScript]
function LoadPostData(
   postDataKey : String,
 postCollection : NameValueCollection
) : Boolean;

Parameters

postDataKey
The key identifier for the control.
postCollection
The collection of all incoming name values.

Return Value

true if the server control's state changes as a result of the post back; otherwise false.

Remarks

The Web Forms page framework tracks all the server control's that return true to this method call, then invokes the RaisePostDataChangedEvent on those controls.

Example

[Visual Basic, C#, C++] The following example demonstrates a server control implementing a version of the LoadPostData method.

[Visual Basic] 
Public Overridable Function LoadPostData(postDataKey As String, _
   postCollection As NameValueCollection) As Boolean
       
    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


[C#] 
public virtual bool LoadPostData(string postDataKey,
   NameValueCollection postCollection) {

   String presentValue = Text;
   String postedValue = postCollection[postDataKey];

   if (presentValue == null || !presentValue.Equals(postedValue)){
      Text = postedValue;
      return true;
   }
   return false;
}
  

[C++] 
public:
 virtual bool LoadPostData(String* postDataKey,
    NameValueCollection* postCollection) {

    String* presentValue = Text;
    String* postedValue = postCollection->Item[postDataKey];

    if (presentValue == 0 || !presentValue->Equals(postedValue)){
       Text = postedValue;
       return true;
    }
    return false;
 }
   

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ 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

IPostBackDataHandler Interface | IPostBackDataHandler Members | System.Web.UI Namespace | Processing Postback Data

Show: