ASP.NET directives are special instructions to CLR about the behaviour and operations of the webforms.Every ASP.NET page contains directives.In other words,these directives are commands that the compiler uses when the page is compiled.We can control the behaviour of page by using directives.It doesn't matter that the page uses code-behind model or the inline-coding model,we can use directives in our application.
Directive is opened with .The format of a directive is as follows :
<%@[Directive] Attribute=value %>
we can add more than one attribute to directive statements as follows:
<%@[Directive] Attribute=value Attribute=value %>
There are 11 directives in ASP.NET 2.0.
Page - when the page is complied the @Page directive enables us to use attributesand values for an .aspx page.
Control - Enable us to use with user controls(.ascx).
Register - Registers one .ascx file to web-page[.aspx].
OutputCache - Used for Client-side caching.
Import - Imports a Namespace[Package] into the page.
Implements - Implements one Interface to web-form[.aspx/.ascx].
Reference - Used for Page To Page Data Transfer.
Assembly - Includes one Assembly[.dll] to the application.
PreviousPagetype - Enables the page in an application to work with postback from other Page.Master - Defines one Master[.master] Page.MasterType - Uses a class name to a page within specified master page.
Tips:
(1.)Although page still compiles if we put these directives at a different place in the page but it is good programming practice to put these directives at the top of our page or control.
(2.)@Page and @Control directives can not be used at the same time in .aspx page.
[4:21 PM
|
0
comments
]
0 comments
Post a Comment