IPostBackDataHandlerとは? わかりやすく解説

IPostBackDataHandler インターフェイス

ポストバック データを自動的に読み込むために ASP.NET サーバー コントロールで実装する必要があるメソッドを定義します。

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Interface IPostBackDataHandler
Dim instance As IPostBackDataHandler
public interface IPostBackDataHandler
public interface class IPostBackDataHandler
public interface IPostBackDataHandler
public interface IPostBackDataHandler
解説解説
使用例使用例

IPostBackDataHandler インターフェイスを実装するカスタム テキスト ボックス サーバー コントロールのコード例を次に示します。ポストバックの結果、Text プロパティが変更され、サーバー コントロールは、ポストバック データが読み込まれた後に TextChanged イベントを発生させます。

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

using System;
using System.Web;
using System.Web.UI;
using System.Collections;
using System.Collections.Specialized;


namespace CustomWebFormsControls {

   [System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand,
 Name="FullTrust")] 
   public class MyTextBox: Control, IPostBackDataHandler
 {
    

      public String Text {
         get {
            return (String) ViewState["Text"];
         }

         set {
            ViewState["Text"] = value;
         }
      }      
      

      public event EventHandler TextChanged;
      

      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 virtual void RaisePostDataChangedEvent()
 {
         OnTextChanged(EventArgs.Empty);
      }
      

      protected virtual void OnTextChanged(EventArgs
 e) {
         if (TextChanged != null)
            TextChanged(this,e);
      }
      

      protected override void Render(HtmlTextWriter
 output) {
         output.Write("<INPUT type= text name = "+this.UniqueID
            + " value = " + this.Text + " >");
      }
   }   
}
   
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

IPostBackDataHandler メソッド


IPostBackDataHandler メンバ




英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「IPostBackDataHandler」の関連用語











IPostBackDataHandlerのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



IPostBackDataHandlerのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS