Technical Training
VB.NET 2005Table of Contents
VB.NET Creating and Managing Components Part 2
VB.NET Creating and Managing Components Part 2 - Page 2VB.NET Creating and Managing Components Part 2
Creating and Managing Components Part 2
In Section 2 of Creating and Managing Components You will learn about Hosting a control inside Internet Explorer, HTMLAnchor Control, HTMLButton Control, HTMLGeneric Control, Creating Components by extending the Control class, Creating a custom control and Creating components by extending the Component class.
Hosting a control inside Internet Explorer
ASP .NET server controls are group of new controls provided by .NET. They are of different kinds. HTML Server controls, Web Server controls and Validation controls are the other types. These controls derive from System.Object -> System.Web.UI.Control -. HtmlControl.
.
.
.
.
.
.
Some of the controls are listed below:
| Control | Related HTML Tag |
|
HtmlAnchor |
Allows access to program against the < a > tag |
| HTMLButton | Allows access to program against the< button > tag |
|
HTMLForm |
Allows access to program against the < form > tag |
| HTMLGeneric | Allows access to HTML tags that are not represented by any HTML server control specifically |
|
HTMLImage |
Allows access to program against the < img > tag |
These controls are hosted in the browser by using codes which are discussed below:
HTMLAnchor Control
This control allows access to program the HTML tag. An example is shown below:
Aspx file code:
Code behind page code:
You can now see the control hosted in the browser:

HTMLButton Control
HTMLButton Control allows the user program the HTMLtag. This is the tag used to place clickable buttons within HTML documents. This is achieved by the following code:
The code that is written in the aspx page:
The code that is written in the code behind page:
The page when viewed in a browser looks like the screenshot below:

HTMLGeneric Control
HTMLGeneric control allows the user program the HTML tags that are not represented by any of the specified controls. Some of the examples are < span >, < div >, < body > and so on. The following demo illustrates the use of HTMLGeneric Control to access the HTML tag.
The codes that are given in the aspx page are given below:
The codes that are given in the code behind page are given below:
The view of the page in the browser is shown below:

Creating Components by extending the Control class
Components can be created by extending a control class. This feature enables the application developer in numerous ways. He can create customized components for his application using the basic functionality of the component as his starting point.
To start with, a library of derived controls can be created out of predefined controls. These controls can then be customized by adding specific functionalities. The features of the base class can also be extended by adding few properties that are essential to the application being developed.
Ads
Creating a custom control
1. Create a new control library project in the visual studio.
2. Right-click on the solution explorer and add a new custom control.
You will see a screen like the one you see below:

Controls can be dragged and dropped for customization. For the purposes of study, let us drag and drop a label control. The codes for this control will be displayed in the code window. Now add the following code to the class:
VB.NET 2005
- VB.NET 2005 Free Training
- The .NET Framework Architecture Part 1
- The .NET Framework Architecture Part 2
- Application Class and Message Class
- Implementing Class Library Object
- Visual Studio.NET Namespaces
- .NET Assemblies
- Differences between VB.NET 1.0 and VB.NET 2.0
- Introducing VB.NET Windows Forms
- Visual Studio Windows Forms Designer
- Exploring the Forms Designer generated code
- Setting and Adding Properties to Windows Form
- Implementing Inheritance
- Event Handling In Visual Basic .NET
- Building Graphical Interface elements
- .NET Common Windows Forms Controls Part 1
- .NET Common Windows Forms Controls Part 2
- Common Controls and Handling Control Events
- DomainUpDown and NumericUpDown Controls
- Dialog Boxes in Visual Basic .NET
- Visual Studio Adding Controls to Windows Form
- VB.NET Validation Controls
- Working with Menu Controls
- VB.NET MDI Applications
- .NET Exceptions
- VB.NET Creating and Managing Components Part 1
- VB.NET Creating and Managing Components Part 2
- Simple Data Binding
- .NET Complex Data Binding
- .NET Data Form Wizard
- Data Manipulation with ADO.NET
- SQL Server Stored Procedures
- SQL Server Ad Hoc Queries
- Finding and Sorting Data in DataSets
- ADO.NET Object Model
- Working with DataSets
- Using XML Data
- Working with File System in .NET
- Creating Web Service
- Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
- Web Reference and Web Services
- Web Services - SOAP, WSDL, Disco and UDDI
- Web Application Testing in VB.NET 2005
- Web Application Tracing and Debugging
- Working with Legacy Code and COM Components
- ActiveX Controls and Legacy Code
- Windows Application Testing
- VB.NET Windows Application Testing
- Tracing VB.NET Windows Application
- Debugging Windows Applications In Visual Studio.NET 2005
- Deploying Windows Applications In Visual Studio.NET 2005
- Customizing Setup Project in Visual Studio.NET 2005
- Shared Assembly
- Microsoft .NET Creating Installation Components
- The Registry Editor in Visual Studio.NET 2005
- The File Types Editor







