Configuration with Directives


In earlier chapters, you saw and used directives. First, in Chapter 13 in the section "Sample Code for Web Applications," you saw the Page directive when I briefly dis cussed the manner in which the Web page was configured to use a code-behind file. The following code snippet, which is taken from Chapter 13, should look familiar:

 <%@ Page language="cobol" Codebehind="WebForm1.aspx.cob"  AutoEventWireup="false" Inherits="WebApplicationSampleCobol.WebForm1" %> 

Then, as you progressed through the book you arrived at Chapter 15. In that chapter in the section "Using Output Cache," I introduced the OutputCache directive. I discussed the syntax that you use with this directive when you want to configure the output cache setup for your Web application. The following code snippet, which is taken from Chapter 15, is provided for your convenience:

 <%@ OutputCache Duration="10" VaryByParam="None" %> 

The Family of .NET Directives

The directives, whether used on the Web page (.aspx) or on the user control (.ascx), will influence, control, and direct the behavior of your application. In other words, you use directives to configure your application. The two .NET directives you were introduced to earlier are part of a slightly larger group of .NET directives . The com plete set of .NET directives follows (notice that the common syntax of each directive requires the at symbol [@] be appended):

@ Page

@ OutputCache

@ Control

@ Reference

@ Register

@ Import

@ Implements

@ Assembly

You can use the directives in the preceding list to configure your ASP.NET applications. Listing 18-1 shows the basic syntax for each directive to give you a better idea as to the use and capability of each.

Listing 18-1: . The Basic Syntax of Each .NET Directive
start example
  <%@ Page  attribute  ="  value  " [  attribute  ="  value  ". . .] %>  <%@  OutputCache Duration  ="#ofseconds"  Location  ="Any  Client  Downstream      Server  None"  VaryByControl  ="controlname" VaryByCustom="browser      customstring"  VaryByHeader  ="headers"  VaryByParam  ="parametername"  %  >  <%@ Control  attribute  ="  value"  [  attribute  ="  value". . .  ] %>  <%@ Reference page  control="pathtofile" %> <%@ Register  tagprefix  ="tagprefix"  Namespace  ="namespace"  Assembly  =  "  assembly  "  %>  <%@ Register tagprefix="tagprefix" Tagname="tagname" Src="pathname" %>  <%@ Import namespace="value" %> <%@ Implements interface="ValidInterfaceName" %> <%@ Assembly Name="assemblyname" %> <%@ Assembly Src="pathname" %> 
end example
 

You will want to familiarize yourself with each directive. I suggest starting with (or rather returning to) the Page directive. When configuring your ASP.NET appli cations with directives, you will use this directive more than any other. From there, it will depend on the needs of your application. For example, when you create ASP.NET user controls, you will use the Control and Register directives to complete your ASP.NET user control configuration.

Tip  

The following four attributes, which are available for you to use with the Page directive, will be of particular interest to you: Buffer , ClientTarget , EnableViewState , and Trace .

Beyond that, I refer you to the existing documentation available on Microsoft's MSDN Library Web site and your local Microsoft Visual Studio .NET documentation tool.

Tip  

Please use the link ms-help://MS.VSCC/MS.MSDNVS/cpgenref/ html/cpconpagedirectives.htm within your Microsoft Visual Studio .NET documentation tool. There you will find an excellent write-up that details the use of each directive.




COBOL and Visual Basic on .NET
COBOL and Visual Basic on .NET: A Guide for the Reformed Mainframe Programmer
ISBN: 1590590481
EAN: 2147483647
Year: 2003
Pages: 204

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net