asp.net.ph

Skip Navigation Links

@ Control

ASP.NET Syntax   ASP.NET Page Syntax   Page 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.
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.
CompilerOptions Any compiler string that indicates compilation options for the page.
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 Indicates that the page should be compiled using the Visual Basic Option Explicit mode. true if option explicit enabled; otherwise, false. The default is false.
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.
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.

Syntax 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" %>
See Also

Web Forms User Controls



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note