Directives in ASP.Net:
ASP.Net directives are instructions to denote optional settings, such as giving a custom control and page language. These settings define how the web forms (.aspx) or user controls (.ascx) pages are operated by the .Net framework.
The syntax for defining a directive is:
<%@ directive_name attribute=value [attribute=value] %>
|
In this section, we will just start the ASP.Net directives and we will need most of these directives throughout the tutorials.
The Application Directive
The Application directive describes application-specific attributes. It is give at the top of the global.aspx file.
The basic syntax for a sample Application directive is:
<%@ Application Language="C#" %>
|
The attributes of the Application directive are:
Attributes
|
Description
|
Inherits
|
the name of the class from which to add
|
Description
|
text description of the application. Compilers and Parsers ignore this
|
Language
|
language needed in code blocks
|
The Assembly Directive
The Assembly directive links the application at parse time or an assembly to the page. This should appear either in the global.asax file for application-wide linking or a user control file or in the page file for linking to a page or user control.
The basic syntax for a sample Assembly directive is:
<%@ Assembly Name ="myassembly" %>
|
The attributes of the Assembly directive are:
Attributes
|
Description
|
Name
|
the name of the assembly to be marked
|
Src
|
the path to the source file to be marked and compiled dynamically
|
The Control Directive
The Control directive is needed with the user controls and seems in the user control (.ascx) files.
The basic syntax for a sample Control directive is:
<%@ Control Language="C#" EnableViewState="false" %>
|
The attributes of the Control directive are:
Attributes
|
Description
|
AutoEventWireup
|
the Boolean value that activates or disables automatic association of events to handlers
|
ClassName
|
file name for the control
|
Debug
|
the Boolean value that activates or disables compiling with debug symbols
|
Description
|
text description of the control page, removed by compiler
|
EnableViewState
|
the Boolean value that shows whether view state is maintained across page requests
|
Explicit
|
for VB language, provides the compiler to use Option Explicit mode
|
Inherits
|
the class from which the control page inherits
|
Language
|
language for script and code
|
Src
|
the filename for the code behind class
|
Strict
|
for VB language, provides the compiler to use the Option Strict mode
|
The Implements Directive
The Implement directive shows that the web page, user control page or master page must relate the given .Net framework interface.
The basic syntax for an Implements directive is:
<%@ Implements Interface="interface_name" %>
|
The Import Directive
The Import directive imports a namespace into user control, a web page pate of application. If the Import directive is given in the global.asax, then it will apply to the whole application. If it is in a page of user control page, then it would relate to that page or control.
The basic syntax for an Import directive is:
<%@ namespace="System.Drawing" %>
|
The Master Directive
The Master directive defines a page file as being the mater page.
The basic syntax for a sample MasterPage directive is:
<%@ MasterPage Language="C#" AutoEventWireup="true"
CodeFile="SiteMater.master.cs" Inherits="SiteMaster" %>
|
The MasterType Directive
The MasterType directive provides a class name to the Master property of a page, to create it strongly typed.
The basic syntax for a MasterType directive is:
<%@ MasterType attribute="value"[attribute="value" ...] %>
|
The OutputCache Directive
The OutputCache directive controls the output caching policies of a page or a user control. We will defines this directive in details, in data caching.
The basic syntax for a OutputCache directive is:
<%@ OutputCache Duration="15" VaryByParam="None" %>
|
The Page Directive
The Page directive describes the attributes related to the page file for the page the compiler and parser.
The basic syntax for a Page directive is:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" Trace="true" %>
|
The attributes of the Page directive are:
Attributes
|
Description
|
AutoEventWireup
|
the Boolean value that activates or disables Page events that are being automatically bound to methods; for example, Page_Load
|
Buffer
|
the Boolean value that activates or disables HTTP response buffering
|
ClassName
|
class name for the page
|
ClientTarget
|
the browser for which server controls should render content
|
CodeFile
|
name of the code behind code file
|
Debug
|
the Boolean value that activates or disables compilation with debug symbols
|
Description
|
text description of the page, removed by the parser
|
ActivatesessionState
|
activates, disables or create session state read-only
|
EnableViewState
|
the Boolean value that activates or disables view state across page requests
|
ErrorPage
|
URL for redirection if an unhandled page exception happen
|
Inherits
|
the name of the other class or code behind
|
Language
|
programming language for code
|
Src
|
file name of the code behind class
|
Trace
|
activates or disables tracing
|
TraceMode
|
shows how trace messages are to be displayed - sorted by time or category
|
Transaction
|
shows if transactions are supported
|
ValidateRequest
|
the Boolean value that shows whether all input data is validated against a hardcoded list of values
|
The PreviousPageType Directive
The PreviousPageType directive gives a class to a page, so that the page is strongly typed.
The basic syntax for a sample PreviousPagetype directive is:
<%@ PreviousPageType attribute="value"[attribute="value" ...] %>
|
The Reference Directive
The Reference directive shows that another page or user control could be compiled and linked to the present page.
The basic syntax for a sample Reference directive is:
<%@ Reference Page ="somepage.aspx" %>
|
The Register Directive
The Register derivative is used for registering the user controls and custom server controls.
The basic syntax for a sample Register directive is:
<%@ Register Src="~/footer.ascx" TagName="footer"
TagPrefix="Tfooter" %>
|
Email based ASP.Net assignment help - homework help at Expertsmind
Are you searching ASP.Net expert for help with Directives in ASP.Net questions? Directives in ASP.Net topic is not easier to learn without external help? We at www.expertsmind.com offer finest service of ASP.Net assignment help and ASP.Net homework help. Live tutors are available for 24x7 hours helping students in their Directives in ASP.Net related problems. Computer science programming assignments help making life easy for students. We provide step by step Directives in ASP.Net question's answers with 100% plagiarism free content. We prepare quality content and notes for Directives in ASP.Net topic under ASP.Net theory and study material. These are avail for subscribed users and they can get advantages anytime.
Why Expertsmind for assignment help
- Higher degree holder and experienced experts network
- Punctuality and responsibility of work
- Quality solution with 100% plagiarism free answers
- Time on Delivery
- Privacy of information and details
- Excellence in solving ASP.Net queries in excels and word format.
- Best tutoring assistance 24x7 hours