Authoring controls

Published 18 October 05 08:53 AM | despos

As you all know controls are an essential part of ASP.NET pages. Building controls is an as much essential part of the skillset of most developers. Authoring controls is quite easier in ASP.NET 2.0 due to a number of intermediate classes that incorporate most of the techniques and practices that you had to code manually in previous versions. I'm sharing some thoughts and code on the ASP.NET DevCenter.

The first installment live is relatively simple as it deals with deriving controls from existing ones. I describe how to build a DropDownList with an additional API to set the colors of the displayed items--but it shows events, custom properties and a bit more. Future articles will cover trickier aspects of control development such as styling, rendering, themes, control state, viewstate, binding, templates.

A journey of thousand miles begins with a single step. That's mine. Enjoy!

Comments

# Ray Fan said on October 19, 2005 01:04 PM:

Dear Dino,

Could you explain the use of ViewState with control's properties, like when to use ViewState, its use compare to ControlState and when should and what happens if page or control's ViewState is truned off for performance reasons etc.

Thank you!
Ray.

# DinoE said on October 19, 2005 01:07 PM:

That is just in the second article that I delivered to MS a while ago. I expect it to go live in a couple of weeks or earlier.

# Ray Fan said on November 2, 2005 06:18 PM:

Dino,

There is a little problem I encountered. When the data bound to the list is not from a data source like a DB but statically put there inside my program, such as this

public class StatesDropDownList : DropDownList {
public StatesDropDownList()
{
Items.Add(new ListItem("Arizona", "AZ"));
.....
}
}

The code stopped working. Right now ApplyItemStyle() is only called inside OnDataBound(). I put
if (!ItemColorMode.Equals(ItemColorMode.Explicit))
{
ApplyItemStyle();
}
at the beginning of RenderContents() to solve it.

Thanks!
Ray.

# Keith Forsyth said on August 10, 2007 05:39 PM:

Great article.  It helped me understand some important concepts.  Thanks!

Keith

Leave a Comment

(required) 
(required) 
(optional)
(required)