O'Reilly logo

ASP.NET by Example by Steven A. Smith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Custom Control of Our Own

As usual, we'll start with the obligatory Hello World example. In this case we're going to create a custom control that does nothing more than output the text “Hello World”. We will see shortly how we can do this by inheriting from existing controls, such as the Label, but for now, we will simply inherit from the base class Control. The source code for our control is listed in Listing 12.1.

Listing 12.1. A C# Hello World Control, HelloWorld.cs
 namespace ASPNETByExample { public class HelloWorld : System.Web.UI.Control { protected override void Render(System.Web.UI.HtmlTextWriter htwOutput) { htwOutput.Write("Hello ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required