Control.Load Control.Load Control.Load Control.Load Event

定義

發生於載入伺服器控制項至 Page 物件時。Occurs when the server control is loaded into the Page object.

public:
 event EventHandler ^ Load;
public event EventHandler Load;
member this.Load : EventHandler 
Public Custom Event Load As EventHandler 

範例

// This is the constructor for a custom Page class. 
// When this constructor is called, it associates the Control.Load event,
// which the Page class inherits from the Control class, with the Page_Load
// event handler for this version of the page.
public MyPage()
{
   Load += new EventHandler(Page_Load);
}
' This is the constructor for a custom Page class. 
' When this constructor is called, it associates the Control.Load event,
' which the Page class inherits from the Control class, with the Page_Load
' event handler for this version of the page.
Public Sub New()
   AddHandler Load, AddressOf Page_Load
End Sub

備註

通知伺服器控制項執行任何設定為在每個頁面要求上進行的處理步驟。Notifies the server control to perform any processing steps that are set to occur on each page request. 您可以從這個事件存取檢視狀態資訊和 Web 表單張貼資料。You can access view state information and Web form POST data from this event. 您也可以存取頁面控制項階層中的其他伺服器控制項。You can also access other server controls within the page's control hierarchy.

注意

如果您在Page_Load事件期間設定控制項中的自訂範本,則會遺失自訂範本中子控制項的文字值。If you set a custom template in a control during the Page_Load event, the text values of child controls in the custom template will be lost. 這是因為表單值已經載入。This occurs because the form values have already been loaded.

適用於

另請參閱