Control.OnLoad(EventArgs) 方法

定義

引發 Load 事件。

C#
protected virtual void OnLoad(EventArgs e);
C#
protected internal virtual void OnLoad(EventArgs e);

參數

e
EventArgs

包含事件資料的 EventArgs 物件。

範例

C#
// Override the OnLoad method to set _text to
// a default value if it is null.
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    if (_text == null)
        _text = "Here is some default text.";
}

備註

ASP.NET 呼叫這個方法來引發 Load 事件。 如果您要開發自定義控件,您可以覆寫這個方法,以提供額外的處理。 如果您覆寫這個方法,請呼叫基底控件的 OnLoad 方法來通知事件的訂閱者。

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

另請參閱