Custom ASP.NET Web Menu Control – Part 1
There is often quite a bit of confusion when it comes to the topic of “custom controls” in the .NET 1.x world. This is mainly due to inconsistent naming conventions used on the different options available in Visual Studio .NET. Terminology such as user controls, web controls, custom controls, control libraries etc… being used to describe different development strategies makes it rather confusing to know exactly what type of control your application should use.
There are in fact 2 options for developing a “custom control” in ASP.NET. A custom control can be used to define either type, which simply means a control not provided by the .NET framework. The 2 options are: 1) Web User Control and 2) Web Control Library.
We’ll review each type in detail later on in the tutorial. This 2 part tutorial will focus on control type #2, a Web Control Library, which provides the greatest flexibility. This type of control is also the most confusing and difficult to implement.
To put this type of control into practical use we’ll build the control around a common topic of interest, which are navigation menus. The purpose of the control is 2-fold, create a reusable control that we can drag and drop onto any ASPX Web Form, and also to provide a completely customized programming experience and tailor the control to our specific needs of the application.
Part 1 of this tutorial will explore the differences between custom controls in more detail and create the framework for a Web Control Library in a sample ASP.NET application. We’ll explore the fundamentals of this type of custom control and demonstrate how to get the basic functionality of the menu working. In Part 2 we will advance upon this framework and build more aesthetics into the interface of the component as well as explore creating Design time properties to reduce code-behind logic.
Note: Visual Studio .NET running ASP.NET 1.x is required for this tutorial. Both VB.NET and C# code samples will be provided