ResourceExpressionEditorSheet 类

定义

在设计时表示设计器宿主 UI 中资源表达式属性的设计时编辑器表。Represents a design-time editor sheet for the properties of a resource expression in the UI of a designer host at design time.

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

示例

下面的代码示例演示如何使用Text ResourceExpressionEditorHyperLink控件的属性绑定到资源表达式。The following code example demonstrates how to bind the Text property of a HyperLink control to a resource expression using the ResourceExpressionEditor. 使用示例:To use the example:

  1. 在网站项目中, 将名为 Strings 的新资源文件添加到 App_GlobalResources 文件夹中。In a Web site project, add a new resource file named Strings.resx to the App_GlobalResources folder.

  2. 将名myLinkText为的字符串添加到字符串 .resx 资源文件中, 并将值设置为HyperLink控件的文本。Add a string named myLinkText to the Strings.resx resource file, and set the value to the text for a HyperLink control. 例如, 将myLinkText字符串值设置为This is a linkFor example, set the myLinkText string value to This is a link.

  3. 在 ASP.NET 网页中, 添加一个HyperLink控件。In an ASP.NET Web page, add a HyperLink control.

  4. Hyperlink控件的属性网格中, 单击 "表达式", 然后单击省略号按钮 (...) 以显示 "表达式绑定" 对话框。In the property grid for the Hyperlink control, click Expressions, and click the ellipsis button (...) to display the expression binding dialog box.

  5. 选择控件Text的属性, 并将Resources expression 类型设置为表达式类型。Select the Text property of a control, and set Expression Type to the Resources expression type. 可视化设计器显示ResourceExpressionEditorSheet对象定义的资源表达式属性。The visual designer displays the resource expression properties defined by the ResourceExpressionEditorSheet object.

  6. 设置表达式属性, 如下所示:Set the Expression Properties as follows:

    • ClassKey设置Strings为, 即已编译的字符串 .resx 资源文件的类名称。Set ClassKey to Strings, the class name for the compiled Strings.resx resource file.

    • ResourceKey设置myLinkText为, 即字符串 .resx 中的字符串名称。Set ResourceKey to myLinkText, the string name in Strings.resx.

可视化设计器使用ResourceExpressionEditor对象为Text属性分配资源表达式。The visual designer uses the ResourceExpressionEditor object to assign the resource expression for the Text property. 下面的 aspx 源显示使用资源表达式设置的属性值的示例:The following aspx source shows an example of a property value set using a resource expression:

<!-- Define a hyperlink that maps the Text property to the
     myLinkText string value in the Strings.resx resource file. -->
<asp:HyperLink runat="server" ID="HyperLink2" 
     Text="<%$ Resources:Strings, myLinkText %>"
     NavigateUrl="http://www.microsoft.com"></asp:HyperLink>
<!-- Define a hyperlink that maps the Text property to the
     myLinkText string value in the Strings.resx resource file. -->
<asp:HyperLink runat="server" ID="HyperLink2" 
     Text="<%$ Resources:Strings, myLinkText%>"
     NavigateUrl="http://www.microsoft.com"></asp:HyperLink>
<FileName>ControlsUsingExpressions.aspx</FileName>
<RelevantItems>
    <Reference>System.Web.UI.Design.ResourceExpressionEditor</Reference>
</RelevantItems>

注解

可视化设计器将ResourceExpressionEditorResourceExpressionEditorSheet与类结合使用, 以选择资源引用表达式的各个属性, 并将所选的资源表达式属性值合并为资源表达式。The visual designer uses the ResourceExpressionEditor class with the ResourceExpressionEditorSheet class to select the individual properties of a resource reference expression, and to combine the selected resource expression property values into a resource expression.

ConnectionStringsExpressionEditor.GetExpressionEditorSheet 方法返回 ResourceExpressionEditorSheet 对象。The ConnectionStringsExpressionEditor.GetExpressionEditorSheet method returns a ResourceExpressionEditorSheet object. 在 "表达式" 对话框中, 选择控件属性并将其绑定到资源表达式时, 可视化设计器将调用GetExpressionEditorSheet方法。In the expressions dialog box, when you select a control property and bind it to a resource expression, the visual designer calls the GetExpressionEditorSheet method. 可视化设计器使用返回ResourceExpressionEditorSheet的对象来提示ClassKey输入和ResourceKey属性。The visual designer uses the returned ResourceExpressionEditorSheet object to prompt for the ClassKey and ResourceKey properties. 选择资源表达式属性后, 可视化设计器会调用GetExpression方法, 将属性合并为资源表达式字符串。Once the resource expression properties are selected, the visual designer calls the GetExpression method to combine the properties into a resource expression string.

必须在资源表达式中指定属性;此属性将为资源值编制索引。ResourceKeyThe ResourceKey property must be specified in a resource expression; it indexes the resource value. ClassKey属性是可选的。The ClassKey property is optional. 它引用定义全局资源文件夹中的资源的类键或文件名。It references the class key or file name that defines the resource in the global resources folder.

构造函数

ResourceExpressionEditorSheet(String, IServiceProvider)

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

属性

ClassKey

获取或设置与项目的全局资源文件夹中资源的文件名匹配的键。Gets or sets the key that matches the filename for the resource in the project's global resource folder.

IsValid

获取一个值,该值指示资源表达式字符串是否有效。Gets a value that indicates whether the resource expression string is valid.

ResourceKey

获取或设置资源的名称,该名称可用作查找资源值的键。Gets or sets the name of the resource, which is used as a key to find the resource value.

ServiceProvider

获取表达式编辑器表使用的服务提供程序实现。Gets the service provider implementation that is used by the expression editor sheet.

(继承自 ExpressionEditorSheet)

方法

Equals(Object)

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

(继承自 Object)
GetExpression()

返回由表达式编辑器表属性值形成的资源表达式。Returns a resource expression that is formed by the expression editor sheet property values.

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)

适用于

另请参阅