Control.OnUnload メソッド
アセンブリ: System.Web (system.web.dll 内)



テキスト ストリーム オブジェクト myFile を作成し、要求処理中に定義済み Page とコントロールの有効期間イベントが発生したときに、このオブジェクトを使用してテキスト ファイルにメッセージを書き込む例を次に示します。OnUnload メソッドを呼び出し中、"Custom control was unloaded" という文字列がファイルに書き込まれ、テキスト ストリーム オブジェクトは終了します。
' Create a StreamWriter to write data to a text file. Dim myFile As TextWriter = File.CreateText("c:\NewTextFile.txt") Sub Page_Load(sender As Object, e As EventArgs) ' Write status to file. myFile.WriteLine("Page has loaded.") End Sub Sub CustomControl_OnLoad(sender As Object, e As EventArgs) myFile.WriteLine("Custom control has loaded.") End Sub Sub CustomControl_OnUnload(sender As Object, e As EventArgs) ' Server controls final cleanup such as; ' closing files etc.goes here myFile.WriteLine("Custom control was unloaded.") ' Close the stream object. myFile.Close() End Sub
// Create a StreamWriter to write data to a text file. TextWriter myFile = File.CreateText("c:\\NewTextFile.txt"); void Page_Load(object sender,EventArgs e) { // Write status to file. myFile.WriteLine("Page has loaded."); } void CustomControl_OnLoad(object sender,EventArgs e) { myFile.WriteLine("Custom control has loaded."); } void CustomControl_OnUnload(object sender,EventArgs e) { // Server controls final cleanup such as; // closing files goes here myFile.WriteLine("Custom control was unloaded."); // Close the stream object. myFile.Close(); }
// Create a StreamWriter to write data to a text file. TextWriter myFile = File.CreateText("c:\\NewTextFile.txt"); void Page_Load(Object sender,EventArgs e) { // Write status to file. myFile.WriteLine("Page has loaded."); } //Page_Load void CustomControl_OnLoad(Object sender,EventArgs e) { myFile.WriteLine("Custom control has loaded."); } //CustomControl_OnLoad void CustomControl_OnUnload(Object sender,EventArgs e) { // Server controls final cleanup such as; // closing files goes here myFile.WriteLine("Custom control was unloaded."); // Close the stream object. myFile.Close(); } //CustomControl_OnUnload

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からControl.OnUnload メソッドを検索する場合は、下記のリンクをクリックしてください。

- Control.OnUnload メソッドのページへのリンク