Substitution イベント

名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。 ( Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。 ( Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。 ( Control から継承されます。) |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。 ( Control から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。 ( Control から継承されます。) |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。 ( Control から継承されます。) |

関連項目
Substitution クラスSystem.Web.UI.WebControls 名前空間
Substitution.MethodName プロパティ
HttpResponseSubstitutionCallback
HttpContext
HttpCachePolicy
Cache
その他の技術情報
Substitution Web サーバー コントロールASP.NET キャッシュ
ASP.NET ページのキャッシュ
ASP.NET ページの一部だけのキャッシュ
キャッシュ ページの動的な部分更新
Substitution クラス
アセンブリ: System.Web (system.web.dll 内)


Substitution コントロールを使用して、出力キャッシュを使用する Web ページのうち、コントロールを動的なコンテンツで置き換えるセクションを指定します。Substitution コントロールは、ほとんどのコンテンツがキャッシュされるページに対して、部分ページ キャッシュを行うよりシンプルなソリューションを提供します。ページ全体を出力キャッシュしてから、Substitution コントロールを使用して、キャッシュしないページ部分を指定できます。キャッシュされる領域は一度だけ実行され、キャッシュ エントリの有効期限が切れるかパージされるまで再生されます。動的領域はページが要求されるたびに実行されます。このキャッシュ モデルでは、セクションをカプセル化して Web ユーザー コントロールにキャッシュする必要がないため、本来は静的であるページのコードが簡略化されています。たとえば、ニュース記事などの静的コンテンツと、広告を表示する AdRotator コントロールを含むページの場合は、このキャッシュ モデルを使用すると便利です。ニュース記事は変更されないのでキャッシュできます。ただし、ユーザーがページを要求するたびに、新しい広告を表示したいとします。AdRotator コントロールはキャッシュ後の置き換えを直接サポートするため、ページがキャッシュされているかどうかにかかわらず、ページがポストバックされるたびに新しい広告を表示します。
![]() |
---|
Substitution コントロールは、キャッシュされるページに含まれるユーザー コントロール内に配置できます。ただし、Substitution コントロールを出力キャッシュされるユーザー コントロール内に配置することはできません。 |
Substitution コントロールは、実行時に文字列を返すメソッドを呼び出します。このメソッドが返す文字列の内容が、ページ上の Substitution コントロールの位置に表示されます。MethodName プロパティを使用して、Substitution コントロールの実行時に呼び出すコールバック メソッドの名前を指定します。指定するコールバック メソッドは、ページ上または Substitution コントロールを格納しているユーザー コントロールの静的メソッドであることが必要です。コールバック メソッドのシグネチャは、HttpContext パラメータを受け取って文字列を返す HttpResponseSubstitutionCallback デリゲートのシグネチャと一致する必要があります。
ページの出力キャッシュを操作するために、@ OutputCache ディレクティブ、HttpCachePolicy クラス、または Cache プロパティを使用できます。ページのキャッシュの詳細については、「ASP.NET ページのキャッシュ」および「ASP.NET ページの一部だけのキャッシュ」を参照してください。
Substitution コントロールを使用する代わりに、HttpResponseSubstitutionCallback デリゲートを使用して、キャッシュの置き換え動作を取得することもできます。また、この機能を直接サポートするコントロール (AdRotator コントロールなど) のキャッシュの置き換え動作を取得することもできます。詳細については、「キャッシュ ページの動的な部分更新」を参照してください。

Substitution コントロールを出力キャッシュを使用する Web ページに宣言によって追加する方法のコード例を次に示します。ページが読み込まれると、ユーザーに対して現在の日付と時刻がラベルに表示されます。ページのこのセクションはキャッシュされ、60 秒ごとに更新されます。Substitution コントロールは、実行時に GetCurrentDateTime メソッドを呼び出します。GetCurrentDateTime から返される文字列がユーザーに表示されます。ページのこのセクションはキャッシュされず、ページの表示が更新されるたびに更新されます。
<%@ outputcache duration="60" varybyparam="none" %> <script runat="server" language="VB"> Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) ' Display the current date and time in the label. ' Output caching applies to this section of the page. CachedDateLabel.Text = DateTime.Now.ToString() End Sub ' The Substitution control calls this method to retrieve ' the current date and time. This section of the page ' is exempt from output caching. Shared Function GetCurrentDateTime(ByVal context As HttpContext) As String Return DateTime.Now.ToString() End Function </script> <html> <head id="Head1" runat="server"> <title>Substitution Class Example</title> </head> <body> <form id="Form1" runat="server"> <h3>Substitution Class Example</h3> <p>This section of the page is not cached:</p> <asp:substitution id="Substitution1" methodname="GetCurrentDateTime" runat="Server"> </asp:substitution> <br /> <p>This section of the page is cached:</p> <asp:label id="CachedDateLabel" runat="Server"> </asp:label> <br /><br /> <asp:button id="RefreshButton" text="Refresh Page" runat="Server"> </asp:button> </form> </body> </html>
<%@ outputcache duration="60" varybyparam="none" %> <script runat="server" language="C#"> void Page_Load(object sender, System.EventArgs e) { // Display the current date and time in the label. // Output caching applies to this section of the page. CachedDateLabel.Text = DateTime.Now.ToString(); } // The Substitution control calls this method to retrieve // the current date and time. This section of the page // is exempt from output caching. public static string GetCurrentDateTime (HttpContext context) { return DateTime.Now.ToString (); } </script> <html> <head runat="server"> <title>Substitution Class Example</title> </head> <body> <form runat="server"> <h3>Substitution Class Example</h3> <p>This section of the page is not cached:</p> <asp:substitution id="Substitution1" methodname="GetCurrentDateTime" runat="Server"> </asp:substitution> <br /> <p>This section of the page is cached:</p> <asp:label id="CachedDateLabel" runat="Server"> </asp:label> <br /><br /> <asp:button id="RefreshButton" text="Refresh Page" runat="Server"> </asp:button> </form> </body> </html>


System.Web.UI.Control
System.Web.UI.WebControls.Substitution


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Substitution コンストラクタ
アセンブリ: System.Web (system.web.dll 内)



Substitution コントロールを出力キャッシュを使用する Web ページにプログラムによって追加する方法のコード例を次に示します。ページが読み込まれると、ユーザーに対して現在の日付と時刻がラベルに表示されます。ページのこのセクションはキャッシュされ、60 秒ごとに更新されます。Substitution コントロールは、実行時に GetCurrentDateTime メソッドを呼び出します。GetCurrentDateTime から返される文字列がユーザーに表示されます。ページのこのセクションはキャッシュされず、ページの表示が更新されるたびに更新されます。
<%@ outputcache duration="60" varybyparam="none" %> <script runat="server" language="VB"> Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) ' Programmatically create a Substitution control. Dim Substitution1 As New Substitution ' Specify the callback method. Substitution1.MethodName = "GetCurrentDateTime" ' Add the Substitution control to the controls ' collection of PlaceHolder1. PlaceHolder1.Controls.Add(Substitution1) ' Display the current date and time in the label. ' Output caching applies to this section of the page. CachedDateLabel.Text = DateTime.Now.ToString() End Sub ' The Substitution control calls this method to retrieve ' the current date and time. This section of the page ' is exempt from output caching. Shared Function GetCurrentDateTime(ByVal context As HttpContext) As String Return DateTime.Now.ToString() End Function </script> <html> <head id="Head1" runat="server"> <title>Substitution Constructor Example</title> </head> <body> <form id="Form1" runat="server"> <h3>Substitution Constructor Example</h3> <p>This section of the page is not cached:</p> <asp:placeholder id="PlaceHolder1" runat="Server"> </asp:placeholder> <br /> <p>This section of the page is cached:</p> <asp:label id="CachedDateLabel" runat="Server"> </asp:label> <br /><br /> <asp:button id="RefreshButton" text="Refresh Page" runat="Server"> </asp:button> </form> </body> </html>
<%@ outputcache duration="60" varybyparam="none" %> <script runat="server" language="C#"> void Page_Load(object sender, System.EventArgs e) { // Programmatically create a Substitution control. Substitution Substitution1 = new Substitution(); // Specify the callback method. Substitution1.MethodName = "GetCurrentDateTime"; // Add the Substitution control to the controls // collection of PlaceHolder1. PlaceHolder1.Controls.Add (Substitution1); // Display the current date and time in the label. // Output caching applies to this section of the page. CachedDateLabel.Text = DateTime.Now.ToString(); } // The Substitution control calls this method to retrieve // the current date and time. This section of the page // is exempt from output caching. public static string GetCurrentDateTime (HttpContext context) { return DateTime.Now.ToString (); } </script> <html> <head id="Head1" runat="server"> <title>Substitution Class Example</title> </head> <body> <form id="Form1" runat="server"> <h3>Substitution Constructor Example</h3> <p>This section of the page is not cached:</p> <asp:placeholder id="PlaceHolder1" runat="Server"> </asp:placeholder> <br /> <p>This section of the page is cached:</p> <asp:label id="CachedDateLabel" runat="Server"> </asp:label> <br /><br /> <asp:button id="RefreshButton" text="Refresh Page" runat="Server"> </asp:button> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Substitution プロパティ



関連項目
Substitution クラスSystem.Web.UI.WebControls 名前空間
MethodName
HttpResponseSubstitutionCallback
HttpContext
HttpCachePolicy
Cache
その他の技術情報
Substitution Web サーバー コントロールASP.NET キャッシュ
ASP.NET ページのキャッシュ
ASP.NET ページの一部だけのキャッシュ
キャッシュ ページの動的な部分更新
Substitution メソッド



関連項目
Substitution クラスSystem.Web.UI.WebControls 名前空間
MethodName
HttpResponseSubstitutionCallback
HttpContext
HttpCachePolicy
Cache
その他の技術情報
Substitution Web サーバー コントロールASP.NET キャッシュ
ASP.NET ページのキャッシュ
ASP.NET ページの一部だけのキャッシュ
キャッシュ ページの動的な部分更新
Substitution メンバ
出力キャッシュを使用する Web ページのうち、キャッシュしないセクションを指定します。この位置で、動的なコンテンツが取得され、Substitution コントロールで置き換えられます。
Substitution データ型で公開されるメンバを以下の表に示します。






名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。(Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。(Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。(Control から継承されます。) |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。(Control から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。(Control から継承されます。) |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。(Control から継承されます。) |

関連項目
Substitution クラスSystem.Web.UI.WebControls 名前空間
MethodName
HttpResponseSubstitutionCallback
HttpContext
HttpCachePolicy
Cache
その他の技術情報
Substitution Web サーバー コントロールASP.NET キャッシュ
ASP.NET ページのキャッシュ
ASP.NET ページの一部だけのキャッシュ
キャッシュ ページの動的な部分更新
Weblioに収録されているすべての辞書からSubstitutionを検索する場合は、下記のリンクをクリックしてください。

- Substitutionのページへのリンク