What are directives ? Which are the directives used in ASP ?

October 28, 2007 · Filed Under ASP.Net Interview Questions, Placement Questions 



Don't want to miss a single bit? Subscribe By Email for Daily Jobs

Enter your email address :

All the latest from JobsAdda on Jobsadda.com delivered to your mailbox everyday.

Directives are used to pass optional settings to the ASP.NET pages and compilers. They typically have the following syntax:

<%@ directive attribute=value [attribute=value] %>

Directives are typically located at the top of the appropriate file, although that is not a strict requirement. For example, Application directives are at the top of the global.asax file, and Page directives are at the top of the .aspx files.

Application directive: The Application directive is used to define application-specific attributes. It is typically the first line in the global.asax file.

Assembly directive: The Assembly directive links an assembly to the application or page at parse-time. The Assembly directive is contained in either the global.asax file, for application-wide linking, or in a page (.aspx) or user control (.ascx) file, for linking to a specific page or user control. There can be multiple Assembly directives in any file. Each Assembly directive can have multiple attribute/value pairs.

Control directive: The Control directive is used only with user controls and is contained in user control files (.ascx). There can only be a single Control directive per .ascx file.

Import directive: The Import directive imports a namespace into a page, user control, or application, making all the classes and namespaces of the imported namespace available.
Page directive: The Page directive is used to define attributes for the page parser and compiler specific to the page (.aspx) file. There can be no more than one Page directive for each page file. Each Page directive can have multiple attributes.

Related Articles


Get Latest JobsAdda.com Jobs, news & updates  via Email