In this article we are going to demonstrate how to attach an image icon with your custom server control. We highly recommend that you check out the previous articles and videos about building RequiredTextBox control.


Creating an ICON for your server control will give it a distinct look in the Toolbox. Control developers try to create the best ICON for their control as they know that a better looking ICON is very important for a control user.


The first thing you need to do is to add an ico file in your project. Right click on your control project and add a new "ico" file. Open the file and select 16X16 dimension. You can use the Visual Studio icon editor to create your icon. The VS editor is very limited so you can always take a look at third party tools or hire someone to create an icon for your control.

Here is the icon we created for our RequiredTextBox control:

The next step is to attach the icon with the RequiredTextBox control. First you must set up the build action of the icon file as "Embedded Resource". Next, attach the attribute to your class as shown below:


Be sure to name the icon same as the name of the control.

And that is pretty much it! Now, when you add the control to your Toolbox it will appear with an icon as shown below:


1) Creating a RequiredTextBox Control in ASP.NET 
2) Screencast: Building RequiredTextBox Custom Control 
3) Screencast: Custom RequiredTextBox with ValidationExpressionValidator
4) Screencast: Injecting Client Script for RequiredTextBox Control
5) Screencast: Building RequiredTextBox Embedding WebResource
6) Screencast: Creating ICON for RequiredTextBox Control

Injection Client Side Script for RequiredTextBox Control


In this article we learned how to attach an ICON with our custom server control. Attaching an attractive ICON with custom control is a must for all third party server control developers.