O'Reilly logo

Programming Visual Basic .NET by Dave Grundgeiger

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

Using Directives to Modify Web Page Compilation

You can modify web page compilation by including directives. Directives are keywords that are recognized and acted on by the ASP.NET page compiler. They affect a page’s compilation, rather than its presentation. Directives are delimited by the characters <%@ and %> and can appear at any location in the source file (although Microsoft says that “standard practice” is to place them at the top of the file). For example, the following <%@ Page %> directive was shown in Example 6-1, earlier in this chapter:

<%@ Page Language="vb" AutoEventWireup="false" 
   CodeBehind="WebForm1.aspx.vb" Inherits="IdeExamples.WebForm1"%>

Directives are similar in form to HTML tags. There is the directive itself, followed by one or more attributes that specify various settings associated with the directive. A directive without attributes has no effect. Directives are different from HTML tags in that the delimiters are different and in that directives have no closing tags.

ASP.NET defines the following directives and associated attributes:

@ Assembly

Provides a way to reference assemblies defined elsewhere. This directive’s attributes are:

Name

Specifies the name of an assembly in the global assembly cache. For example:

<%@ Assembly Name="System.Windows.Forms" %>
SRC

Specifies the path of a Visual Basic .NET source file to be compiled and referenced. The path is relative to the web application’s virtual folder. For example:

<%@ Assembly SRC="SomeClass.vb" ...

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