ASP PAGE STRUCTURE-DIRECTIVES(PAGE DIRECTIVE)

 The following is  the list of the important elements of an ASP.NET page:


  1. Directives
  2. Code declaration blocks
  3. ASP.NET controls
  4. Code render blocks
  5. Server-side comments
  6. Server-side include directives
  7. Literal text and HTML tags

Directives

  • A directive controls how an ASP.NET page is compiled. 
  • The beginning of a directive is marked with the characters <%@ and the end of a directive is marked with the characters %>. 
  • A directive can appear anywhere within a page. By convention, however, a directive typically appears at the top of an ASP.NET page.
  • There are several types of directives that you can add to an ASP.NET page. Two of the most useful types are page and import directives.


Page Directives

  • Page directive  is used to specify the default programming language for a page. 
  • Page directives can also be used to enable tracing and debugging for a page.

  • To change the default programming language of an ASP.NET page from Visual Basic to C#, for example, you would use the following page directive:


<%@ Page Language="C#" %>

  • The keyword Page in a page directive is optional. The following two directives are equivalent:


<%@ Page Language="C#" %>
<%@ Language="C#" %>
DEBUG DIRECTIVE:

  • To enable run time error messages to be displayed on a page, use the Debug directive.
  •  To display errors in  ASP.NET page, include the following directive:


<%@ Page Debug="True" %>

  • When  this directive  is included in the page , if an error is encountered when processing the page, the error is displayed.



No comments:

Post a Comment