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 窗体 POST 数据。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.

适用于

另请参阅