alt
Advertisement
Sponsored links
Online Training
Career Series
Exforsys
Exforsys arrow Tutorials arrow VB.NET 2005 arrow VB.NET Creating and Managing Components Part 2
Site Search


VB.NET Creating and Managing Components Part 2
Article Index
VB.NET Creating and Managing Components Part 2
Page 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:

Click here for Sample Code

Code behind page code:

Click here for Sample 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:

Click here for Sample Code

The code that is written in the code behind page:

Click here for Sample Code

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:

Click here for Sample Code

The codes that are given in the code behind page are given below:

Click here for Sample Code

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.

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:

Click here for Sample Code



 
< Prev   Next >
Exforsys Offers
© 2008 Exforsys.com
Joomla! is Free Software released under the GNU/GPL License.
Page copy protected against web site content infringement by Copyscape