Presentation is loading. Please wait.

Presentation is loading. Please wait.

PAGE DIRECTIVES. Page Directives  They are instructions, inserted at the top of an ASP.NET page, to control the behavior of ASP.NET pages.  So it is.

Similar presentations


Presentation on theme: "PAGE DIRECTIVES. Page Directives  They are instructions, inserted at the top of an ASP.NET page, to control the behavior of ASP.NET pages.  So it is."— Presentation transcript:

1 PAGE DIRECTIVES

2 Page Directives  They are instructions, inserted at the top of an ASP.NET page, to control the behavior of ASP.NET pages.  So it is type of mixed settings related to how a page should render and processed.  There are 11 types of page directives in ASP.NET.  When used, directives can be located anywhere in an.aspx or.ascx file, though standard practice is to include them at the beginning of the file.  Each directive can contain one or more attributes(paired with values) that are specific to that directive.

3 @Page Directive  It enables you to specify attributes and values for an ASP.NET page to be used when the page is parsed and compiled.  Every.aspx files should include this @Page directive to execute. 

4 AttributeValues  AutoEventWireUpThe Boolean value that enables or disables Page events that are being automatically bound to methods; for example, Page_Load  BufferThe Boolean value that enables or disables HTTP response buffering  ClassNameClass name for the page  CodeFileName of the code behind file  DebugThe Boolean value that enables or disables compilation with debug symbols  EnableSessionStateEnables, disables or makes session state read-only  EnableViewStateThe Boolean value that enables or disables view state across page requests  ErrorPageURL for redirection if an unhandled page exception occurs

5 AttributeValues  InheritsThe name of the code behind or other class  LanguageProgramming language for code  SrcFile name of the code behind class  TraceEnables or disables tracing  TraceModeIndicates how trace messages are to be displayed - sorted by time or category

6 @Master Directive  The @Master Directive belongs to Master Pages i.e..master files.  The master page will be used in conjunction of any number of content pages.  So the content pages can inherit the attributes of the master page.  The @Master Directive has only fewer attributes as follows : Language – This attribute tells the complier about the language being used in the code – behind. AutoEventWireUp – For every page there is an automatic way to bind the events to methods in the same master file or in code behind. The default value is true. CodeFile – Specifies the code-behind file with which the Master page is associated.

7 Title – Sets the Master Page title. MasterPageFile – Specifies the location of the Master Page file to be used with the current Master Page. This is called Nested Master Page. EnableViewState Inherits 

8 @Control Directive  It is used when we build an ASP.NET user controls.  The @Control Directive helps us to define the properties to be inherited by the user control.  These values are assigned to the user control as the page is parsed and compiled. 

9 AttributeValues  AutoEventWireUpThe Boolean value that enables or disables automatic association of events to handlers  ClassNameFile name for the control  DebugThe Boolean value that enables or disables compilation with debug symbols  EnableViewStateThe Boolean value that enables or disables view state across page requests  ExplicitFor VB language, tells the compiler to use Option Explicit mode  InheritsThe class from which the control page inherits  LanguageLanguage for code and script  SrcFile name of the code behind class  StrictFor VB language, tells the compiler to use the Option Strict mode

10 @Register Directive  The @Register Directive associates aliases with namespaces and class names for notation in custom server control syntax.  This register the user control on the page so that the control can be accessed on the.aspx page by a specific name.  The main attributes of @Register Directive are : Assembly – The Assembly you are associating with the TagPrefix. Namespace – The namespace to relate with TagPrefix. Src – The location of the user control. TagName – The alias to relate to the class name.

11 TagPrefix – The alias to relate to the namespace. 

12 @Reference Directive  The @Reference Directive declares that another ASP.NET page or user control should be compiled along with the current page or user control.  The main attributes of @Reference Directive are : Control – User Control that ASP.NET should dynamically compile and link to the current page at run time. Page – The Web Form Page that ASP.NET page should dynamically compile and link to the current page at run time. VirtualPath – Specifies the location of the page or user control from which the active page will be referenced. 

13 @PreviousPageType Directive  It is a new directive that makes excellence in asp.net pages.  The concept of cross-page posting between ASP.NET pages is achieved by this directive.  This directive is used to specify the page from which the cross- page posting initiates. TypeName – Sets the name of the derived class from which the postback will occur. VirtualPath – Sets the location of the posting page from which the postback will occur. 

14 @OutputCache Directive  It controls the output caching policies of the ASP.NET page or user control.  You can even cache programmatically through code by using VB.NET or Visual C#.NET  The main attributes of @OutputCache Directive are : Duration – The duration of time in seconds that the page or user control is cached. Location – To specify the location to store the output cache. To store the output cache on the browser client where the request originated set the value as “client”. To store the output cache on the web server, mention the location as “server”. VaryByParam – List of strings used to vary the output cache, separated with semi-colon.

15 VaryByControl – List of strings used to vary the output cache of a user control, separated with semi-colon. VaryByCustom – String of values, specifies the custom output caching requirements. VaryByHeader – List of HTTP headers used to vary the output cache, separated with semi-colon. 

16 @Import Directive  It allows you to specify any namespaces to be imported to the ASP.NET pages or user controls.  By importing, all the classes and interfaces of the namespace are made available to the page or user control. 

17 @Implements Directive  The @Implements Directive gets the ASP.NET page to implement a specified.NET framework interface.  The only single attribute is Interface, helps to specify the.NET framework interface.  When the ASP.NET page or user control implements an interface, it has direct access to all its events, methods and properties. 

18 @Assembly Directive  The @Assembly Directive is used to make your ASP.NET page aware of external components.  This directive supports two attributes :- Name – Enables you to specify the name of an assembly you want to attach to the page. Here you should mention the filename without the extension. Src – Represents the name of a source code file. 

19 @MasterType Directive  To access members of a specific master page from a content page, you can create a strongly typed reference to the master page by creating a @MasterType directive. TypeName – Sets the name of the derived class from which to get strongly typed references or members. VirtualPath – Sets the location of the master page from which the strongly typed references and members will be retrieved.  If you have public properties defined in a master page that you’d like to access in a strongly-typed manner. You can add the MasterType directive into a page as shown :   this.Master.HeaderText = “Label updated using MasterType directive with VirtualPath attribute”


Download ppt "PAGE DIRECTIVES. Page Directives  They are instructions, inserted at the top of an ASP.NET page, to control the behavior of ASP.NET pages.  So it is."

Similar presentations


Ads by Google