Init Event
Collapse the table of content
Expand the table of content

Control.Init Event


Occurs when the server control is initialized, which is the first step in its lifecycle.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

public event EventHandler Init

Server controls should perform any initialization steps that are required to create and set up an instance. You cannot use view-state information within this event; it is not populated yet. You should not access another server control during this event, regardless of whether it is a child or parent to this control. Other server controls are not certain to be created and ready for access. For more information on server control events, see ASP.NET Web Forms Server Control Event Model.

The following example assigns a custom event handler, Calendar_Init, to the Init event of a Calendar control.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<script runat="server">

  protected void Calendar_Init(object sender, EventArgs e)
    // Do any related intialization work.

<html xmlns="" >
<head runat="server">
    <title>Control Init Event Example</title>
    <form id="form1" runat="server">
       <asp:Calendar ID="Calendar1"

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft