System.Web.Compilation.ExpressionBuilder Class

Evaluates expressions during page parsing.

See Also: ExpressionBuilder Members

Syntax

public abstract class ExpressionBuilder

Remarks

The System.Web.Compilation.ExpressionBuilder class is the base class for expression builders, such as the System.Web.Compilation.AppSettingsExpressionBuilder class, that create code expressions during page parsing.

Expression builders parse declarative expressions and create code to retrieve values bound to a control property. In no-compile scenarios, an expression builder that supports a no-compile feature evaluates the expression during run time.

When the page parser encounters an expression that is delimited with the string <%$ %>, it 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 System.Web.Compilation.ConnectionStringsExpressionBuilder object. Prefixes are associated with expression builders in the Web.config file in the System.Web.Configuration.CompilationSection.ExpressionBuilders section.

The right side of the declarative expression is passed to the expression builder for evaluation. Override the ExpressionBuilder.GetCodeExpression(System.Web.UI.BoundPropertyEntry, object, ExpressionBuilderContext) method to generate code that will be compiled with the page.

If you want the custom expression builder to be active on pages that are not compiled, you must also override the ExpressionBuilder.EvaluateExpression(object, System.Web.UI.BoundPropertyEntry, object, ExpressionBuilderContext) method to return an object that represents the results of the expression. You also must override the ExpressionBuilder.SupportsEvaluate property to indicate that the custom expression builder does support no-compile pages.

You can define a set of properties and methods for selecting and evaluating an expression that is associated with a control property at design time by implementing an expression editor. The editor is marked on the expression builder through class-level metadata. For more information, see System.Web.UI.Design.ExpressionEditor.

Requirements

Namespace: System.Web.Compilation
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0