Exforsys.com
 
Home Tutorials VB.NET 2005
 

VB.NET Creating and Managing Components Part 2

 

VB.NET Creating and Managing Components Part 2

Page 1 of 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


Next Page: VB.NET Creating and Managing Components Part 2 - Page 2


Read Next: .NET Assemblies



 

 

Comments


Ken said:

  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 ??
May 7, 2008, 12:41 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape