Sunday, March 12, 2017

Different types of directives in ASP NET

Different types of directives in .NET? @Page: page directive provide the page related operation/attribute, mainy used in compilation or page parser. it is only written in .aspx file at top, like:
<%@ Page  language="C#" %>

@Control: basically used for asp controls, it provide the control related attributes.only in .ascx files it used.
<%@ Control Language="C#"  %>

@Import: import is used when we are required some additiol namespace and we want to import into a specific page or control. it can have one namespace only.
<% @Import Namespace="System.web"%>

@Implements: it is used to show that this page or user control implements some interface.
<%@ Implements Interface="System.Web.UI.IPostBackEventHandler" %>

@Register: it is used to add a control and for that we require to register it first, by using this we can specifically add a customer server control or some user control or skin file.
<%@ Register Tagprefix="uc1" Tagname="AdGrids" Src="AdGrids.ascx" %>

@Assembly: Basically it gives access to an assembly for that page. it makes all classes and methods accessible on the page.
<%@ Assembly Name="BarCode" %>

@OutputCache: output cache is a technique to enable cache on that page.
<%@ OutputCache Duration="60" VaryByControl="*" %>

@Reference: In which page this directive is declared it shows that page/control sholuld first complete compile and link to this page.

No comments:

Post a Comment