How to use Page directive in ASP.NET 4.0

Each .aspx page, or ASP.NET web forms, has three sections. The first section is the Page directive:

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>

The page directive gives ASP.NET basic information about how to compile the page. It indicates:

– the language you’re using for your code

– the way you connect your event handlers.

If you’re using the recommended code-behind approach, the page directive points:

– where the code file is located

– the name of your custom page class.

Notes:

1. You don’t need to modify the page directive by hand, because Visual Studio 2010 maintains it for you.

2. The page directive doesn’t appear in the HTML that’s sent to the browser—instead, ASP.NET strips it out.