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 'New

備註

告知伺服器控制項執行設定為在每個頁面要求上進行任何處理步驟。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.

適用於

另請參閱