Prev | Current Page 102 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"


The simplicity is shown in the tags present in the .ascx file in Listing 2-5. The code-behind
class in Listing 2-6 is left unchanged from the blank template Visual Studio produces when you
add a user control to a web application.
Listing 2-5. The MenuUserControl User Control .ascx File
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="MenuUserControl.ascx.cs"
Inherits="ControlsBook2Web.Ch02.MenuUserControl" %>

Listing 2-6. The MenuUserControl User Control Code-Behind Class File
using System;
namespace ControlsBook2Web.Ch02
{
public partial class MenuUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
The Control directive at the top of the user control .ascx file shown in Listing 2-5 identifies
it as a user control to the ASP.NET parsing engine. The format is similar to that of the Page
directive in an .aspx page file.
The Control directive helps set up the code-behind system through its CodeFile and Inherits
properties.


Pages:
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114