DOT NET 4.0 – Directives for Web Forms Pages – @ Control Directives

Defines user-control (.ascx file) specific attributes that are used by the ASP.NET page parser and compiler. This directive can be used only with user controls.

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

Attributes

AutoEventWireup

Indicates whether the page’s events are autowired. true if event auto wiring is enabled; otherwise, false. The default is true. For more information, see Web Server Control Event Model.

ClassName

Specifies the class name for the page that will by automatically compiled dynamically when the page is requested. This value can be any valid class name, but should not include a namespace.

CompilerOptions

A string containing compiler options used to compile the user control. In C# and Visual Basic .NET, this is a sequence of compiler command line switches.

Debug

Indicates whether the page should be compiled with debug symbols. true if the page should be compiled with debug symbols; otherwise, false.

Description

Provides a text description of the page. Supports any string description.

EnableViewState

Indicates whether view state for the user control is maintained across page requests. true if view state is maintained; otherwise, false. The default is true.

Explicit

Determines whether the page 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 .NET. Also, this option is set to true in the machine.config configuration file. For more information, see Machine Configuration Files.

Inherits

Defines a code-behind class for the user control to inherit. Can be any class derived from the UserControl class. For information about code-behind classes, see Web Forms Code Model.

Language

Specifies the language used when compiling all inline-rendering (<% %> and <%= %>) and server-side script blocks within the user control. Values can represent any .NET-supported language, including Visual Basic, C#, or JScript .NET.

Strict

Indicates that the page 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 .NET.

Src

Specifies the source file name of the code-behind class to dynamically compile when the user control is requested. You can choose to include programming logic for your page either in a code-behind class or in a code declaration block in the .ascx file.

Note RAD designers, such as Visual Studio .NET, do not use this attribute. Instead, they precompile code-behind classes and then use the Inherits attribute.

WarningLevel

Indicates the compiler warning level at which you want the compiler to abort compilation for the user control. Possible values are 0 through 4. For more information, see the CompilerParameters.WarningLevel Property property.

Remarks

This directive can only be used in user controls. User controls are defined in files with the .ascx extension. You can only include one @ Control directive per .ascx file.

Example

The following code instructs the ASP.NET page compiler to use Visual Basic as the inline code language and disables saving view state across HTTP requests using the EnableViewState attribute.

<%@ Control Language="VB" EnableViewState="false" %>

Reference : Dilip Kumar Jena ( https://mstechexplore.wordpress.com )

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s