Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

TemplateControl.Construct Method

Performs design-time logic.

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

'Declaration
Protected Overridable Sub Construct

The Construct method allows design-time code execution of the Page and UserControl controls.

The following code example demonstrates how to override the Construct method of a custom control that is derived from the TemplateControl class.

For the full definition of the MyControl class, see TemplateControl.

 ' Create an event for this user control 
 Public Event myControl As System.EventHandler

 ' Override the default constructor. 
 Protected Overrides Sub Construct()
     ' Specify the handler for the OnInit method. 
     AddHandler Me.myControl, AddressOf MyInit
 End Sub 

 Protected Overrides Sub OnInit(ByVal e As EventArgs)
     RaiseEvent myControl(Me, e)
     Response.Write("The OnInit() method is used to raise the Init event.")
 End Sub 


 ' Use the MyInit handler to set the Message property 
 Sub MyInit(ByVal sender As Object, ByVal e As System.EventArgs)
     Message = "Hello World!" 
 End Sub

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1
Show:
© 2015 Microsoft