IPostBackDataHandler.LoadPostData(String, NameValueCollection) 方法

定义

当由某个类实现时,它为 ASP.NET 服务器控件处理回发数据。

public:
 bool LoadPostData(System::String ^ postDataKey, System::Collections::Specialized::NameValueCollection ^ postCollection);
public bool LoadPostData (string postDataKey, System.Collections.Specialized.NameValueCollection postCollection);
abstract member LoadPostData : string * System.Collections.Specialized.NameValueCollection -> bool
Public Function LoadPostData (postDataKey As String, postCollection As NameValueCollection) As Boolean

参数

postDataKey
String

控件的主要标识符。

postCollection
NameValueCollection

所有传入名称值的集合。

返回

如果回发导致服务器控件的状态发生更改,则为 true;否则为 false

示例

下面的代码示例演示了实现 方法版本的 LoadPostData 服务器控件。

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;
}
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) OrElse (Not presentValue.Equals(postedValue)) Then 
        Text = postedValue
        Return True
    End If
    Return False
End Function

注解

ASP.NET 页框架跟踪返回 true 此方法调用的所有服务器控件,然后对这些控件调用 RaisePostDataChangedEvent 方法。

适用于

另请参阅