AppSettingsExpressionEditor 类

定义

提供用于在设计时计算和编辑配置文件中的应用程序设置表达式的属性和方法。Provides properties and methods for evaluating and editing an application setting expression in a configuration file at design time.

public ref class AppSettingsExpressionEditor : System::Web::UI::Design::ExpressionEditor
public class AppSettingsExpressionEditor : System.Web.UI.Design.ExpressionEditor
type AppSettingsExpressionEditor = class
    inherit ExpressionEditor
Public Class AppSettingsExpressionEditor
Inherits ExpressionEditor
继承
AppSettingsExpressionEditor

示例

下面的代码示例演示如何使用NavigateUrl AppSettingsExpressionEditor对象将HyperLink控件的属性绑定到应用程序设置表达式。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. 在 web 窗体项目中, MyHyperLinkSetting将添加<appSettings>到 web.config 文件的节中。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>
    
  2. 在 Web 窗体页上, 添加HyperLink一个控件。On a Web Forms page, add a HyperLink control.

  3. 对于控件, 在 "属性" 中单击 "表达式", 然后单击省略号按钮 (...)。 HyperlinkFor the Hyperlink control, in Properties, click Expressions, and then click the ellipsis button (...).

    此时<Hyperlinkname>将显示 "表达式" 对话框。The <Hyperlinkname>Expression dialog box appears.

  4. 在 "可绑定属性" 下, 单击 " NavigateUrl", 在 "表达式类型" 列表中单击 " AppSettings", 然后在 "表达式属性" 下的 " AppSetting " 框中, 键入MyHyperLinkSettingUnder Bindable properties, click NavigateUrl, in the Expression type list, click AppSettings, and then under Expression properties, in the AppSetting box, type MyHyperLinkSetting.

可视化设计器使用AppSettingsExpressionEditorNavigateUrl属性分配表达式。The visual designer uses the AppSettingsExpressionEditor to assign the expression for the NavigateUrl property.

下面的 aspx 源显示了使用应用程序设置表达式设置的属性值的示例。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>
<!-- 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>

注解

AppSettingsExpressionEditor类派生ExpressionEditor自类, 并提供用于在设计时计算应用程序设置引用并将其与控件属性关联的实现。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. 例如, 可以将控件属性的值绑定到应用程序设置表达式, 该表达式AppSettings:mySettingKeyName指示使用 Web 配置文件的appSettings部分中的mySettingKeyName值设置控件属性值。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.

可视化设计器宿主 (如Visual Studio 2005Visual Studio 2005) AppSettingsExpressionEditor使用类从appSettings配置节中选择一个应用程序设置, 然后计算所选表达式的设计时呈现。A visual designer host, such as Visual Studio 2005Visual 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.

当您在 "设计Expressions时属性" 网格中浏览到控件的属性时, 可视化设计器将显示一个对话框, 用于设置为控件属性提供运行时值的表达式。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. 从列表中选择AppSettings表达式前缀时, 可视化设计器宿主使用关联ExpressionEditorSheet的对象来提供表达式的appSettings设计时编辑功能, 并使用AppSettingsExpressionEditor方法基于应用程序设置表达式的语法来计算和转换表达式字符串。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.

对象的属性ExpressionPrefix将返回字符串AppSettingsAppSettingsExpressionEditorThe ExpressionPrefix property for an AppSettingsExpressionEditor object returns the string AppSettings. 类与表达式前缀AppSettingsAppSettingsExpressionEditor实现相关联。 AppSettingsExpressionBuilderThe AppSettingsExpressionBuilder class is associated with the expression prefix AppSettings and the AppSettingsExpressionEditor implementation.

EvaluateExpression方法计算输入应用程序设置表达式字符串。The EvaluateExpression method evaluates an input application setting expression string. 方法返回用于输入和编辑应用程序设置表达式的实现。ExpressionEditorSheet GetExpressionEditorSheetThe GetExpressionEditorSheet method returns the ExpressionEditorSheet implementation that is used to enter and edit application setting expressions.

构造函数

AppSettingsExpressionEditor()

初始化 AppSettingsExpressionEditor 类的新实例。Initializes a new instance of the AppSettingsExpressionEditor class.

属性

ExpressionPrefix

获取表达式前缀,该前缀标识受表达式编辑器实现支持的表达式字符串。Gets the expression prefix that identifies expression strings that are supported by the expression editor implementation.

(继承自 ExpressionEditor)

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
EvaluateExpression(String, Object, Type, IServiceProvider)

计算应用程序设置表达式字符串,并为控件属性提供设计时值。Evaluates an application setting expression string and provides the design-time value for a control property.

GetExpressionEditorSheet(String, IServiceProvider)

返回应用程序设置表达式的表达式编辑器表。Returns an expression editor sheet for an application setting expression.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅