The Basics of Creating Server Controls
page 1 of 7
Published: 01 Jan 2004
Unedited - Community Contributed
Abstract
Server Controls can be very powerful if used correctly... and if you are willing to try to break new barriers by creating your own server controls, you will be rewarded greatly by being able to reuse the server control in other applications that you have planned down the road. This first in a series of articles on server controls covers the basics.
by Justin Lovell
Feedback
Average Rating: 
Views (Total / Last 10 Days): 51856/ 92

Foreword

Download the C# source used in this article.
Download the VB.NET source in this article.

In classic ASP, our code was a mix of in-line scripts and HTML. It was very easy for anyone, with logical thinking, to write the code for a dynamic web page. The reason was simple – the steps of the code that was ran was from top to bottom. Wherever there was HTML, it outputted the HTML. When the page parser found a script block, it would then translate it into a small program/applet and then it would be executed. If any output was required from these script blocks, it was a matter of using the Response.Write method. As ASP developers got familiar with their technology, they wanted to reuse repetitive code and scale out their application. There was workarounds such as having common file includes with methods and functions but did not address a true scalable solution. There was the ability to create server/ActiveX components but this was only an option to the people who were not on shared hosting plans or for the people with hosts that did allowed the installation of the components for a fee.

This area is where ASP.NET excels in over its predesor. Server controls is the answer to a scalable design and reusable code for outputting common user interfaces. Microsoft ships with built-in server controls that will do almost any general task from input fields, to buttons, to displaying data in a table (DataGrid). Likewise, with classic ASP, as time progresses and as your knowledge of the .NET framework begins to mature, you will start to demand more control of those server controls from doing repetitive tasks such as data binding.

Fortunately, we are not stuck completely as we found ourselves in classic ASP. We are able to extend the built-in server controls at a very easy level and with a great deal of comfort. We can achieve this by inheriting from the server control that we want to extend its functionality or to change the behaviour of. Furthermore, we can create a whole new server control for new functionality and interaction that could not be provided by the built-in server controls.

Over a series of articles, I will be writing about different aspects of creating server controls for ASP.NET - the articles will span over a few months. This article series is not aimed for beginners but is aimed for intermediate programmers and beyond. As far as this article is concerned, we will be dealing with:

  • The basics of server controls.
  • Cover very briefly of the essential internal workings of ASP.NET pages.

View Entire Article

User Comments

Title: How do I put this control on a page?   
Name: G Shields
Date: 2010-07-21 11:53:01 PM
Comment:
Okay, so I have the inherited custom control class. How do I put it in my page?
Title: Need a translator   
Name: Rob
Date: 2009-05-18 2:24:18 PM
Comment:
Overall I found this article helpful, in some places though the English is so bad that it is practically illegible. As a result, I may have missed some of the finer points.
Title: Simply The Great   
Name: Dot Net Lover
Date: 2008-12-18 10:26:30 PM
Comment:
An Excellent Article.
Thanx for writing.
10 out of 10.
Title: Spell check please   
Name: bszom
Date: 2007-05-23 4:33:57 AM
Comment:
Lame-man's terms? Please, this article would be 3x as good had it been spell-checked.
Title: BRILLIANT explanations and structure!   
Name: Magnus B
Date: 2007-01-26 11:56:21 AM
Comment:
Thank you for gathering what I need to know in such a professional and independent page. Just the way I would ;)
Title: Good work   
Name: Narendra S. Jakhotia
Date: 2006-11-07 4:50:52 AM
Comment:
this topic Cleared most of my concepts on creating controls. I need help from U . I want to combine properties of Image button and Label please tell me how can I do it?
If possible please help me out.naren_pict@yahoo.co.in
Title: Excellent Example   
Name: Jayesh Chudasama
Date: 2006-09-01 2:22:23 AM
Comment:
Great Example!! It outlines all basic needs to understand to create server control.
Title: The Basics of Creating Server Controls   
Name: Jan Waiz
Date: 2005-08-04 11:53:17 AM
Comment:
Perfect!
Title: your history on classic ASP   
Name: JP
Date: 2005-08-03 3:42:12 AM
Comment:
You history on Classic ASP is not quite right. Classic ASP supported use of functions and subroutines which allowed code to be placed anywhere in your page. It also supported use of code classes and window script components (WSC). WSC files are components in XML format which did not have to be registered on the server.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-28 9:07:23 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search