Control.OnUnload メソッドとは? わかりやすく解説

Control.OnUnload メソッド

Unload イベント発生させます

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

Protected Friend Overridable
 Sub OnUnload ( _
    e As EventArgs _
)
Dim e As EventArgs

Me.OnUnload(e)
protected void OnUnload (
    EventArgs e
)

パラメータ

e

イベント データ格納している EventArgs オブジェクト

解説解説
使用例使用例

テキスト ストリーム オブジェクト 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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からControl.OnUnload メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からControl.OnUnload メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からControl.OnUnload メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Control.OnUnload メソッド」の関連用語

Control.OnUnload メソッドのお隣キーワード
検索ランキング

   

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



Control.OnUnload メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS