add Element for expressionBuilders for compilation (ASP.NET Settings Schema)
Adds a reference to an expression builder to the collection.
This element is new in the .NET Framework version 2.0.
<add
expressionPrefix = "prefix"
type = "type"
/>
Attributes and Elements
The following sections describe attributes, child elements, and parent elements.
Attributes
Attribute | Description |
---|---|
expressionPrefix |
Required String attribute. Specifies the prefix for the expression. This string is the left side of an expression as it appears in an .aspx page, for example:
This is the collection key. The default is an empty string (""). |
type |
Required String attribute. Specifies the name of the expression builder class that handles this expression. This can be a custom class that derives from the ExpressionBuilder class. The default is an empty string (""). |
Child Elements
None.
Parent Elements
Element | Description |
---|---|
configuration |
Specifies the root element in every configuration file that is used by the common language runtime and the .NET Framework applications. |
system.web |
Specifies the root element for the ASP.NET configuration section. |
compilation |
Configures all compilation settings that ASP.NET uses to compile applications. |
expressionBuilders |
Defines a collection of resource strings to use during compilation. The resource strings associate prefixes with expression builders. This element is new in the .NET Framework version 2.0. |
Remarks
The add element adds a reference to an expression builder to the collection.
The expressionBuilders element defines a collection of resource strings to use during compilation. The resource strings associate prefixes with expression builders.
When the page parser encounters an expression in an .aspx page that is delimited with the string <%$ %>
, the parser creates an expression builder for the expression based on the prefix in the string. The prefix is the portion of the string that is to the left of the colon (:). For example, when the parser encounters the string <%$ ConnectionStrings:MessageDB %>
, it creates a ConnectionStringsExpressionBuilder object. For more information, see ExpressionBuilder.
Default Configuration
The following default expressionBuilders element is not explicitly configured in the Machine.config file or in the root Web.config file. However, it is the default configuration that is returned by application. Items are added to the expressionBuilders collection in the root Web.config file.
<expressionBuilders>
<clear />
</expressionBuilders>
The following default expressionBuilders element is configured in the root Web.config file.
<expressionBuilders>
<add expressionPrefix="Resources" type="System.Web.Compilation.ResourceExpressionBuilder" />
<add expressionPrefix="ConnectionStrings" type="System.Web.Compilation.ConnectionStringsExpressionBuilder" />
<add expressionPrefix="AppSettings" type="System.Web.Compilation.AppSettingsExpressionBuilder" />
</expressionBuilders>
Example
The following code example shows how to register a custom expression builder in the Web.config file. A custom expression builder must implement the ExpressionBuilder abstract class.
To reference the expression in an .aspx file, use the following sytax:
<asp:Label ID="Label1" runat="server"
Text="<%$ MyCustomExpression:Hello, world! %>" />
<configuration>
<system.web>
<compilation>
<expressionBuilders>
<add expressionPrefix="MyCustomExpression"
type="MyCustomExpressionBuilder"/>
</expressionBuilders>
</compilation>
</system.web>
</configuration>
Element Information
Configuration section handler |
|
Configuration member |
|
Configurable Locations |
Machine.config Root-level Web.config Application-level Web.config Virtual or physical directory–level Web.config |
Requirements |
Microsoft Internet Information Services (IIS) version 5.0, 5.1, or 6.0 The .NET Framework version 2.0 Microsoft Visual Studio 2003 or Visual Studio 2005 |
See Also
Tasks
How to: Configure Specific Directories Using Location Settings
How to: Lock ASP.NET Configuration Settings
Reference
assemblies Element for compilation (ASP.NET Settings Schema)
remove Element for expressionBuilders for compilation (ASP.NET Settings Schema)
clear Element for expressionBuilders for compilation (ASP.NET Settings Schema)
configuration Element (General Settings Schema)
system.web Element (ASP.NET Settings Schema)
compilation Element (ASP.NET Settings Schema)
System.Configuration
System.Web.Configuration
CompilationSection
Add
Concepts
ASP.NET Compilation Model
ASP.NET Web Page Code Model
ASP.NET Web Site Precompilation Overview
ASP.NET Configuration File Hierarchy and Inheritance
Securing ASP.NET Configuration
ASP.NET Configuration Scenarios
Other Resources
General Configuration Settings (ASP.NET)
ASP.NET Configuration Settings
Configuring ASP.NET Applications
ASP.NET Configuration Files
ASP.NET Configuration API