Tutorials
VB.NET 2005
VB.NET Creating and Managing Components Part 2
VB.NET Creating and Managing Components Part 2 - Page 2In 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.
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:
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 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 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:

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.
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:
Next Page: VB.NET Creating and Managing Components Part 2 - Page 2
|
While the article addresses many components - I find some things are lacking - such as creating html components with no closing end tag such as these are not created with the generic control - so how do you build them ?? |