Net-informations.com
SiteMap  | About    

Page Directives in Asp.Net

Directives

The directives are instructions that specify optional settings in Asp.Net, but they are not rendered as part of the HTML page return to the client browser. These instructions include registering a custom control, page language etc. It describes how the .aspx pages (web forms) or .ascx pages (user controls) are processed by the .Net framework.

Page directive

page-directive

The most commonly used directive is the @ Page directive and it can be used only in Web Forms. Page directive allows you to specify many configuration options for the page. By default, Visual Studio creates a page directive as shown below:

C# <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> VB.NET <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

You can include only one @ Page directive in your .aspx file. Also you should specify one language in the Language attribute. This can be any .NET Framework-supported language, including VB.Net, C#, or JScript.

AutoEventWireup controlled the automatic binding of page events based on the method naming convention. The default is true, which performs the automatic lookup and binding. If it is set to False then you should create methods with any name and bind them to page events explicitly

CodeFile specifies a path to the referenced code-behind file for the page. Inherits defines the name of the class from which to inherit. This can be any class derived from the Page class









net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.