Showing posts with label CompilerOptions. Show all posts
Showing posts with label CompilerOptions. Show all posts

Saturday, October 10, 2009

Directive Syntax @ Control

Directive Syntax @ Control

The @Control directive is used in an Asp.Net user controls. The @Control directive helps us to define control-specific attributes to be used by the ASP.NET control parser and compiler Hence it can be used only with .ascx (User Control) files.

The attributes of @Control directives are

a. Language: This Attribute is same as we read in the Page directive.

Value: Is a valid string which can represent any .NET-supported language, including VB || C# || Pearl || Jscript || any other .NET
Purpose: Tell the compiler about the language being used in the code-behind file.

b. AutoEventWireup: This Attribute is same as we read in the Page directive.
Value: Can be true || False. By Default value is true.
Purpose: For every page in a .net website there is an automatic way to bind the events to their corresponding methods in the same .ascx file and code behind.

c. CodeFile: This Attribute is same as we read in the Page directive.
Value: Any string which specifies the name of the code-behind file.
Purpose: Specifies the associated code-behind file of the page.


d. EnableViewState: This Attribute is same as we read in the Page directive.
Value: True || False The default is true.
Purpose: Tells whether view state is maintained across page requests. true to maintain view state is; otherwise, false.

e. Inherits: This Attribute is same as we read in the Page directive.
Value: any string
Purpose: Specifies a code-behind class name which the page will inherit. It can be any class which inherits the Page class.

f. Debug:
Value: Can be true || false
Purpose: This value indicates that the page should compile with debug symbols or without debug symbols.

g. Src:
Value: Any Valid String
Purpose: Tells the source file of the class i.e the file used as the code behind file of this user control.

The other attributes which we rarely use are ClassName, CompilerOptions, ComplieWith, Description, EnableTheming, Explicit, LinePragmas, Strict and WarningLevel.

An example of how a @Control directive looks


For more details Visit MSDN

Subscribe via email

Enter your email address:

Delivered by FeedBurner

MSDotnetMentor

MSDotnetMentor My Website http://msdotnetmentor.com