Explain different types of directives in .NET [Resolved]

Posted by Shweta_Pinky under ASP.NET on 6/29/2013 | Points: 10 | Views : 1164 | Status : [Member] | Replies : 2
Please tell me about different types of directives in .NET




Responses

Posted by: Satyapriyanayak on: 6/29/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
@Page: Defines page-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .aspx files <%@ Page AspCompat="TRUE" language="C#" %>

@Control:Defines control-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .ascx files. <%@ Control Language="VB" EnableViewState="false" %>

@Import: Explicitly imports a namespace into a page or user control. The Import directive cannot have more than one namespace attribute. To import multiple namespaces, use multiple @Import directives. <% @ Import Namespace="System.web" %>

@Implements: Indicates that the current page or user control implements the specified .NET framework interface.<%@ Implements Interface="System.Web.UI.IPostBackEventHandler" %>

@Register: Associates aliases with namespaces and class names for concise notation in custom server control syntax.<%@ Register Tagprefix="Acme" Tagname="AdRotator" Src="AdRotator.ascx" %>

@Assembly: Links an assembly to the current page during compilation, making all the assembly's classes and interfaces available for use on the page. <%@ Assembly Name="MyAssembly" %><%@ Assembly Src="MySource.vb" %>

@OutputCache: Declaratively controls the output caching policies of an ASP.NET page or a user control contained in a page<%@ OutputCache Duration="#ofseconds" Location="Any | Client | Downstream | Server | None" Shared="True | False" VaryByControl="controlname" VaryByCustom="browser | customstring" VaryByHeader="headers" VaryByParam="parametername" %>

@Reference: Declaratively indicates that another user control or page source file should be dynamically compiled and linked against the page in which this directive is declared.


If this post helps you mark it as answer
Thanks

Shweta_Pinky, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: aswinialuri-19361 on: 6/30/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi Shweta,
11 types of directives are there .
But most common directive is @page directive
1)@Page:Defines page-specific attributes used by the ASP.NET page parser and compiler and can be included only in .aspx files.

2)@Assembly:Links an assembly to the current page or user control declaratively

3)@Control: Defines control-specific attributes used by the ASP.NET page parser and compiler and can be included only in .ascx files (user controls).


4)@Outputcache:Controls the output caching policies of a page or user control declaratively.


5)@Reference: Links a page, user control, or COM control to the current page or user control declaratively.


6)@Implements: Indicates that a page or user control implements a specified .NET Framework interface declaratively.


7)@Import: Imports a namespace into a page or user control explicitly.


8)@Master: Identifies a page as a master page and defines attributes used by the ASP.NET page parser and compiler and can be included only in .master files.


9)@MasterType: Defines the class or virtual path used to type the Master property of a page.


10)@Previouspagetype: Creates a strongly typed reference to the source page from the target of a cross-page posting.

11)@Register: Associates aliases with namespaces and classes, which allow user controls and custom server controls to be rendered when included in a requested page or user control.



Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Shweta_Pinky, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response