Web Form Syntax

Similar to Active Server Pages, Web Forms are text files consisting of HTML tags and other controlling tags such as directives and script blocks. The default extension for web forms is aspx ; however, you can use the IIS administration tool to map other file extensions explicitly with aspnet_isapi.dll to have them parsed and compiled when accessed, as if they were ASP.NET resources.

There are ten different syntax elements in ASP.NET; because most of them are carried over from ASP, we list here the familiar ones and discuss only those that are important in ASP.NET:

Directives
Code declaration blocks
Code rendering blocks
HTML control syntax
Custom control syntax
Data-binding expressions
Server-side object tags
Server-side include directives
Server-side comments
Literal text

Directives

Previously, all ASP directives were formatted as <%@ [ attribute=value ] + %> because there was only one type of directive.[43]

ASP.NET adds a number of directives to ASP.NET files. With the new list of directives—Page, Control, Import, Register, Assembly, and OutputCache—the syntax for directive is now <%@ directive [ attribute=value ] + %>. All of the old ASP directives are attributes under the Page directive. If you use the old syntax by omitting the directive name, the attribute/value pairs will be applied to the default directive, which is Page.

@ Page

In addition to containing all previous ASP directives (CodePage, EnableSessionState, Language, LCID, and Transaction), the ASP.NET ...

Get .Net Framework Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.