The Basics of Creating Server Controls
page 2 of 7
by Justin Lovell
Feedback
Average Rating: 
Views (Total / Last 10 Days): 51854/ 85

The Basic Concept of the User Interface in ASP.NET

One of the main critera is for a "server control" to qualify as a server control, the class must inherit from System.Web.UI.Control class, directly or indirectly. Another main critera for one to qualify as a server control is the ability to output some type of text into the HTTP request; either or all of the following:

  • Client side scripts.
  • Html mark-up.
  • Contain other server controls as children.

With that said, time for you to swallow the big red pill – a page (the one at System.Web.UI.Page) is a server control as well. It does qualify for both of the main criterion. Think that you got a fright when you read that a page is a server control? Then just read on...

Lets add more complexity - every ounce of text and “static” HTML is a server control as well. Here is the interesting part – text can defy this behaviour (get converted to a server control) can be manipulated so that the text can become part of the control (known as extended or advanced properties). With the text out of the way (either a server control or part of a server control), the page parser finalizes the page.

When the page is being finalized the following will occur - all controls that contain other controls are then sorted into the parent-children relationship (the parents are also known as container controls). To accomplish this, AddParsedSubObject method is then used by the page parser. By default, the method will take the instance of the control (that was found "underneath" the current control) and then cast it as a Control class. This method will then take the control and then place it under a ControlCollection class - namely, the Controls property.

While the AddParsedSubObject method is being executed (adding the controls from the page parser), the ControlCollection class is doing what its constructor asked for the instaintation to create the ControlCollection – telling the new controls who their “parent” is. This is required by unique identification of the controls for various reasons. The page parser works from the top of the page hierarchy and works “deeper” into the control tree - moving in a left to right and a top to bottom fashion.

When those controls gets its content "underneath" themselves, the process started all over again until the entire page has been parsed. Now the Page is ready to begin its life cycle.

As we go across more articles in the series, we will pick up other essential bits and pieces that makes a control, a control (no pun intended). Although I did explain this section in a very brief manner, there is nothing really to lure on about the internal workings of the user interface in ASP.NET.


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-29 5:10:42 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search