Making skinned custom controls

Overview

This article will show you how you can easily make your custom controls skinned by deriving from a new control class that we will call SkinControl. SkinControl is an abstract class and derives from Control class, and introduces a new property and a few methods. These methods and the property is what will actually build the skin – one of the methods, Initialize, needs to be overridden by each control you want to be skinned. This must be done because it is in this method where you initialize all the HTML- and web controls that you want to control and that are part of the skin.

The skins will be user controls, in other words, .ASCX files. This makes it a very simple process to update the skins for your controls as you don't need to re-compile anything – all you need to do is to alter the HTML in the skin file and the update will be instantaneous (unless you of course choose to cache the skin files).

Note: the technique seen in this article is based upon the skinning technique as seen in ASP.NET Forums code.

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“In order to understand recursion, one must first understand recursion.”