The directives section is one of the most important parts of an ASP.NET page. Directives control how a page is compiled, specify how a page is cached by web browsers, aid debugging (error-fixing), and allow you to import classes to use within your page’s code. Each directive starts with <%@. This is followed by the directive name, plus any attributes and their corresponding values. The directive then ends with %>.
There are many directives that you can use within your pages, and we’ll discuss them in greater detail later. For the moment, however, know that the Import and Page directives are the most useful for ASP.NET development. Looking at our sample ASP.NET page, Hello.aspx, we can see that a Page directive was used at the top of the page like so:
Visual Basic LearningASP\VB\Hello.aspx (excerpt)
<%@ Page Language="VB" %>
C# LearningASP\CS\Hello.aspx(excerpt)
<%@ Page Language="C#" %>
In this case, the Pagedirective specifies the language that’s to be used for the application logic by setting the Language attribute. The value provided for this attribute, which appears in quotes, specifies that we’re using either VB or C#. A whole range of different directives is available; we’ll see a few more later in this chapter.
ASP.NET directives can appear anywhere on a page, but they’re commonly included at its very beginning.
There are many directives that you can use within your pages, and we’ll discuss them in greater detail later. For the moment, however, know that the Import and Page directives are the most useful for ASP.NET development. Looking at our sample ASP.NET page, Hello.aspx, we can see that a Page directive was used at the top of the page like so:
Visual Basic LearningASP\VB\Hello.aspx (excerpt)
<%@ Page Language="VB" %>
C# LearningASP\CS\Hello.aspx(excerpt)
<%@ Page Language="C#" %>
In this case, the Pagedirective specifies the language that’s to be used for the application logic by setting the Language attribute. The value provided for this attribute, which appears in quotes, specifies that we’re using either VB or C#. A whole range of different directives is available; we’ll see a few more later in this chapter.
ASP.NET directives can appear anywhere on a page, but they’re commonly included at its very beginning.