O'Reilly logo

Programming ASP .NET by Dan Hurwitz, Jesse Liberty

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

Chapter 5. ASP Control Details

The previous chapter briefly discussed the different types of controls available in ASP.NET. It went into some detail on HTML server controls and gave an introductory example of ASP server controls. While the latter are sometimes also referred to as web server controls, in the context of this book we call them, simply, ASPcontrols, to reflect the syntax used to implement them:

<asp:controlType
      id="ControlID"
      runat="server" />

Notice that the control tag always begins with asp:.

This chapter provides a wealth of detail about ASP controls. It covers the features and properties common to many of these controls and surveys the specific details of all the ASP controls included with the .NET Framework.

The Basics

In this section, you will create a simple web page, in either C# or VB.NET, in which you will explore many of the properties, events, and methods common to all ASP controls. Example 5-1 shows csASPServerControlBasics1.aspx, the first iteration in C#, and Example 5-2 shows vbASPServerControlBasics1.aspx, the equivalent file in VB.NET. These two examples demonstrate a Label control, an event handler, and properties being set for a control.

Example 5-1. Basic web page in C#, csASPServerControlBasics.aspx

<%@ Page Language="C#" %> <script runat="server"> void lblTime_Init(Object Source, EventArgs E) { lblTime.Font.Name = "Verdana"; lblTime.Font.Size = 20; lblTime.Font.Underline = true; lblTime.Font.Bold = true; lblTime.Font.Italic = true; lblTime.Font.Overline ...

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