What are different types of directives in .NET?


  • @Page:   
    It defines page specific attributes used by the ASP.NET page parser and compiler. Can be included only in .aspx files
E.g.:

<%@ Page AspCompat="TRUE" language="C#" %>
  • @Control:  
    It defines control specific attributes used by the ASP.NET page parser and compiler. It can be included only in .ascx files.

    E.g.:

    <%@ 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.

    E.g.:

    <% @ Import Namespace="System.web" %>
  • @Implements:   
    This indicates that the current page or user control implements the specified .NET framework interface.

    E.g.:

    <%@ Implements Interface="System.Web.UI.IPostBackEventHandler" %>
  • @Register:   
    It associates aliases with namespaces and class names for concise notation in custom server control syntax.

    E.g.:

    <%@ 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.

    E.g.:    <%@ 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

    E.g.:    <%@ OutputCache Duration="#offseconds"

    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.

0 comments :

Post a Comment

> Related Posts with Thumbnails
 

Copyright © 2012. GS dot net - All Rights Reserved - Design by BTDesigner - Proudly powered by Blogger