Sideway
output.to from Sideway





Draft for Information Only

Content

ASP.NET @ Webpage Directives
  @ Assembly
   Syntax
   Attributes
  Remarks
  @ Control
   Syntax
   Attributes
  Attribute Values
  Remarks
  @ Implements
   Syntax
   Attributes
  Remarks
  Source/Reference

ASP.NET @ Webpage Directives

The webpage directives for web form and user control are @ Assembly:, @ Control, @ Implements, @ Import, @ Master, @ MasterType, @ OutputCache, @ Page, @ PreviousPageType, @ Reference, and @ Register.

@ Assembly

The @ Assembly is used to link an assembly to an ASP.NET application file, such as a web page, a user control, a master page, or a global.asax file, during compilation in order to make all the assembly's classes and interfaces available for use.

Syntax

<%@ Assembly Name="assemblyname" %>
<%@ Assembly Src="pathname" %> 

Attributes

@ AssmemblyKeywords of @ Assmebly directive NameAttribute keyword used to specify assembly by name assemblynameA string that represents the name of the assembly to link. The specified assembly name does not include a file name extension. SrcAttribute keyword used to specify assembly by source pathnameThe path to a source file to dynamically compile and link against.

Remarks

  • Either a Name or a Src attribute must be included in an @ Assembly directive, but both Name and Src attributes can not be included within the same @ Assembly directive. If both Name and Src attributes are needed to be used in @ Assembly, multiple @ Assembly directives must be used  in the file in order to include both Name and Src attributes seperatedly.
  • The @ Assembly directive can be used in .aspx pages, .ascx files, .master pages and .asax files.
  • The compiler references the assembly at compile time, allowing early binding. After compilation of the requested ASP.NET file is complete, the assembly is loaded into the application domain, allowing late binding.
  • Assemblies that reside in the Web application's \Bin directory are automatically linked to ASP.NET files within that application. Such assemblies do not require the @ Assembly directive. This automatic function can be disable this functionality by removing the following line from the <assemblies> section of the application's Web.config file: <add assembly="*"/>
  • As an alternative to using the @ Assembly directive, the Web.config file can also be used to link assemblies across an entire application.

@ Control

The @ Control directive is used to define attributes that are used by the ASP.NET page parser and compiler. The @ Control directive is specifically used for user controls file. In other words, the @ Control directive can be used only with whose source code is contained in user controls files with .ascx file extension.

Syntax

<%@ Control attribute="value" [attribute="value" ... ] %>

Attributes

@ ControlKeywords of @ Control directive attributeSpecified keywords from a list of attribute name used to specify attribute of @ Control attribute. "value"The specified value of the specified attribute of @ Control attribute.

Attribute Values

AutoEventWireupIndicates whether the control's events are autowired. true if event autowiring is enabled; otherwise, false. The default is true. ClassNameA string that specifies the class name for the control that will be dynamically compiled when the control is requested. This value can be any valid class name and can include the full namespace of a class (a fully qualified class name). If a value for this attribute is not specified, the class name for the compiled control is based on the control's file name. Another page or control can reference the class name assigned to the control by using the @ Reference directive. ClientIDModeSpecifies the algorithm to use to generate ClientID values for controls. The default value for a page is AutoID. The default value for controls is Inherit. Therefore, the default algorithm for controls in a user control is determined by the ClientID setting of the user control. A different default value can be set at the page level in the @ Page directive or in the pages element of the Web.config file. CodeBehindSpecifies the name of the compiled file that contains the class associated with the control. This attribute is not used at run time. Note: This attribute is included for compatibility with previous versions of ASP.NET, to implement the code-behind feature. In ASP.NET version 2.0, you should instead use the CodeFile attribute to specify the name of the source file, along with the Inherits attribute to specify the fully qualified name of the class. CodeFileSpecifies a path to the referenced code-behind file for the control. This attribute is used together with the Inherits attribute to associate a code-behind source file with a user control. The attribute is valid only for compiled controls. CodeFileBaseClassSpecifies a path to a base class for a control and its associated code-behind class. This attribute is optional, but when it is used the CodeFile attribute must also be present. Use this attribute when you want to implement a shared scenario, where you define common fields (and optionally, associated events) in a base class to reference the controls declared in a user control. Because of the ASP.NET code generation model, if you defined the fields in a base class without using the this attribute, at compile time new member definitions would be generated for the controls declared in the user control (within a separate partial class stub), and your desired scenario would not work. But if you use the CodeFileBaseClass attribute to associate the base class with the user control, and you make your partial class (its name is assigned to the Inherits attribute and its source file is referenced by the CodeFile attribute) inherit from the base class, then the fields in the base class will be able to reference the controls in the user control after code generation. CompilationModeSets whether the control should be compiled, using a string that specifies one of several enumerated options. The default value is Always, so .aspx controls are compiled by default. CompilerOptionsA string containing compiler options used to compile the control. In C# and Visual Basic, this is a sequence of compiler command-line switches. DebugIndicates whether the control should be compiled with debug symbols. true if the control should be compiled with debug symbols; otherwise, false. Because this setting affects performance, you should only set the attribute to true during development. DescriptionProvides a text description of the control. This value is ignored by the ASP.NET parser. EnableThemingIndicates whether themes are used on the control. true if themes are used; otherwise, false. The default is true. EnableViewStateIndicates whether view state is maintained across control requests. true if view state is maintained; otherwise, false. The default is true. ExplicitDetermines whether the control is compiled using the Visual Basic Option Explicit mode. true indicates that the Visual Basic explicit compile option is enabled and that all variables must be declared using a Dim, Private, Public, or ReDim statement; otherwise, false. The default is false. Note: This attribute is ignored by languages other than Visual Basic. Also, this option is set to true in the Machine.config configuration file. InheritsDefines a code-behind class for the control to inherit. This can be any class derived from the UserControl class. Used with the CodeFile attribute, which contains the path to the source file for the code-behind class. LanguageSpecifies the language used when compiling all inline rendering (<% %> and <%= %>) and code declaration blocks within the control. Values can represent any .NET Framework-supported language, including Visual Basic, C#, or JScript. Only one language can be used and specified per control. LinePragmasDetermines whether the runtime should generate line pragmas in the source code. These are compiler options that are often used by debugging tools to mark specific locations in a source file. true if line pragmas should be generated; otherwise, false. SrcSpecifies a path to a source file containing code that is linked to the control. In the linked source file, you can choose to include programming logic for your control either in a class or in code declaration blocks. You can use the Src attribute to link build providers to the control. For more information, see the BuildProvider class. Also, in versions of ASP.NET prior to 2.0, the Src attribute was used as an alternative way to link a code-behind file to a control. In ASP.NET version 2.0, the preferred approach to linking a code-behind source file to a control is to use the Inherits attribute to specify a class, along with the CodeFile attribute to specify the path to the source file for the class. StrictIndicates that the control should be compiled using the Visual Basic Option Strict mode. true if Option Strict is enabled; otherwise, false. The default is false. Note This attribute is ignored by languages other than Visual Basic. TargetSchemaSpecifies the name of a schema that validates content on the control. This serves only a descriptive purpose; no actual validation is performed, and the attribute is ignored by the parser. WarningLevelIndicates the compiler warning level at which you want the compiler to treat warnings as errors, thus aborting compilation of the control. Possible warning levels are 0 through 4. For more information, see the WarningLevel property.

Remarks

  • ASP.NET treats any directive block (<%@ %>) that does not contain an explicit directive name as an @ Page directive (for a page) or as an @ Control directive (for a user control).
  • The @ Control directive can be used only in user controls. User controls are defined in files with the .ascx extension.
  • Only one @ Control directive can be included per .ascx file.
  • Further, only one Language attribute can  be defined per @ Control directive, because only one language can be used per control.
  • The @ Control directive has a number of attributes in common with other directives that apply to an entire source file, such as the @ Page directive (used in .aspx files for Web pages) and the @ Master directive (used in .master files for master pages).
  • To define multiple attributes for the @ Control directive, separate each attribute/value pair with a single space. For a specific attribute, do not include a space on either side of the equal sign (=) that connects the attribute with its value.

@ Implements

The @ Implements directive is used to indicate that the current ASP.NET application file (Web page, user control, or master page) implements the specified .NET Framework interface.

Syntax

<%@ Implements interface="ValidInterfaceName" %>

Attributes

@ ImplementsKeywords of @ Implements directive interfaceAttribute keyword used to specify interface to be implemented on the page or user control by name "ValidInterfaceName"The specified ValidInterfaceName of the valid interface of @ Implement directive.

Remarks

  • When implementing an interface in a Web Forms page, the interface's events, methods, and properties can be created between the opening and closing tags of a <script> element in a code declaration block.
  • The @ Implements can not be use to implement an interface in a code-behind file.

Source/Reference

  • https://docs.microsoft.com/en-us/previous-versions/t8syafc7(v=vs.140)
  • https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/d864zc1k(v=vs.100)
  • https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/d19c0t4b(v=vs.100)
  • https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/cbsf6k72(v=vs.100)

©sideway
close

References

  1. Active Server Pages, http://msdn.microsoft.com/en-us/library/aa286483.aspx, updated 20Dec2012
  2. ASP Overview, http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx, updated 21Dec2012
  3. ASP Best Practices, http://technet.microsoft.com/en-us/library/cc939157.aspx, updated 15Apr2013
  4. ASP Built-in Objects, http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx, updated 20Dec2012
  5. Response Object, http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx, updated 20Dec2012
  6. Request Object, http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx, updated 20Dec2012
  7. Server Object (IIS), http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx, updated 20Dec2012
  8. Application Object (IIS), http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx, updated 20Dec2012
  9. Session Object (IIS), http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx, updated 20Dec2012
  10. ASPError Object, http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx, updated 20Dec2012
  11. ObjectContext Object (IIS), http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx, updated 20Dec2012
  12. Debugging Global.asa Files, http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx, updated 15Apr2013
  13. How to: Debug Global.asa files, http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx, updated 15Apr2013
  14. Calling COM Components from ASP Pages, http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx, updated 15Apr2013
  15. IIS ASP Scripting Reference, http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx, updated 15Apr2013
  16. ASP Keywords, http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx, updated 15Apr2013
  17. Creating Simple ASP Pages, http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx, updated 15Apr2013
  18. Including Files in ASP Applications, http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx, updated 15Apr2013
  19. ASP Overview, http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx, updated 15Apr2013
  20. FileSystemObject Object, http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx, updated 14Mayr2013
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx, ADO Object Model, updated 15Apr2013
  22. ADO Fundamentals, http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx, updated 14Mayr2013
close

ID: 190600027 Last Updated: 2019/6/27 Revision: Ref:

IMAGE

Home (5)

Business

Management

HBR (3)

Information

Recreation

Hobbies (7)

Culture

Chinese (1097)

English (336)

Reference (66)

Computer

Hardware (149)

Software

Application (187)

Digitization (24)

Numeric (19)

Programming

Web (618)new

CSS (SC)

ASP.NET (SC)

HTML

Knowledge Base

Common Color (SC)

Html Entity (Unicode) (SC)

Html 401 Special (SC)

OS (388)new

MS Windows

Windows10 (SC)

.NET Framework (SC)

DeskTop (7)

Knowledge

Mathematics

Formulas (8)

Number Theory (206)

Algebra (20)

Trigonometry (18)

Geometry (18)

Calculus (67)

Complex Analysis (21)

Engineering

Tables (8)

Mechanical

Mechanics (1)

Rigid Bodies

Statics (92)

Dynamics (37)

Fluid (5)

Fluid Kinematics (5)

Control

Process Control (1)

Acoustics (19)

FiniteElement (2)

Biology (1)

Geography (1)


Copyright © 2000-2019 Sideway . All rights reserved Disclaimers last modified on 10 Feb 2019