Export (0) Print
Expand All

AppSettingsExpressionEditor Class

Provides properties and methods for evaluating and editing an application setting expression in a configuration file at design time.

System.Object
  System.Web.UI.Design.ExpressionEditor
    System.Web.UI.Design.AppSettingsExpressionEditor

Namespace:  System.Web.UI.Design
Assembly:  System.Design (in System.Design.dll)

public class AppSettingsExpressionEditor : ExpressionEditor

The AppSettingsExpressionEditor type exposes the following members.

  NameDescription
Public methodAppSettingsExpressionEditorInitializes a new instance of the AppSettingsExpressionEditor class.
Top

  NameDescription
Public propertyExpressionPrefixGets the expression prefix that identifies expression strings that are supported by the expression editor implementation. (Inherited from ExpressionEditor.)
Top

  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodEvaluateExpressionEvaluates an application setting expression string and provides the design-time value for a control property. (Overrides ExpressionEditor.EvaluateExpression(String, Object, Type, IServiceProvider).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetExpressionEditorSheetReturns an expression editor sheet for an application setting expression. (Overrides ExpressionEditor.GetExpressionEditorSheet(String, IServiceProvider).)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The AppSettingsExpressionEditor class is derived from the ExpressionEditor class and provides an implementation for evaluating and associating an application setting reference with a control property at design time. For example, you can bind the value of a control property to the application setting expression AppSettings:mySettingKeyName, which indicates that the control property value is set using the mySettingKeyName value in the appSettings section of the Web configuration file.

A visual designer host, such as Visual Studio 2005, uses the AppSettingsExpressionEditor class to select an application setting from the appSettings configuration section, and then evaluates the selected expression for design-time rendering.

When you browse to the Expressions property for a control in the design-time properties grid, the visual designer displays a dialog box to set expressions that provide the run-time value for a control property. You can select the expression type based on a list of expression prefixes. When you select the AppSettings expression prefix from the list, the visual designer host uses the associated ExpressionEditorSheet object to provide design-time editing functionality of appSettings expressions and uses AppSettingsExpressionEditor methods to evaluate and convert the expression string based on the syntax for an application setting expression. The visual designer host uses the evaluated expression result to assign control property values that are rendered on the design surface.

The ExpressionPrefix property for an AppSettingsExpressionEditor object returns the string AppSettings. The AppSettingsExpressionBuilder class is associated with the expression prefix AppSettings and the AppSettingsExpressionEditor implementation.

The EvaluateExpression method evaluates an input application setting expression string. The GetExpressionEditorSheet method returns the ExpressionEditorSheet implementation that is used to enter and edit application setting expressions.

The following code example demonstrates how to bind the NavigateUrl property of a HyperLink control to an application setting expression using the AppSettingsExpressionEditor object.

  1. In a Web Forms project, add MyHyperLinkSetting to the <appSettings> section of the web.config file.

    <FileName>web.config</FileName>
    <RelevantItems>
        <Reference>System.Web.UI.Design.AppSettingExpressionEditor</Reference>
    </RelevantItems>
    
    	<appSettings>
    		<add key="MyHyperLinkSetting" value="http://www.microsoft.com" />
    	</appSettings>
    
  2. On a Web Forms page, add a HyperLink control.

  3. For the Hyperlink control, in Properties, click Expressions, and then click the ellipsis button (...).

    The <Hyperlinkname> Expression dialog box appears.

  4. Under Bindable properties, click NavigateUrl, in the Expression type list, click AppSettings, and then under Expression properties, in the AppSetting box, type MyHyperLinkSetting.

The visual designer uses the AppSettingsExpressionEditor to assign the expression for the NavigateUrl property.

The following aspx source shows an example of a property value set using an application setting expression.

<!-- Define a hyperlink that maps the NavigateUrl property to the
     MyHyperLinkSetting value in the Web.Config appSettings section. -->
<asp:HyperLink runat="server" ID="HyperLink1" 
     NavigateUrl="<%$ AppSettings:MyHyperLinkSetting %>">
     HyperLink using an AppSetting expression
</asp:HyperLink>
<FileName>ControlsUsingExpressions.aspx</FileName>
<RelevantItems>
    <Reference>System.Web.UI.Design.AppSettingExpressionEditor</Reference>
</RelevantItems>

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft