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
- 继承
示例
下面的代码示例演示如何 Text 使用将控件的属性绑定 HyperLink 到资源表达式 ResourceExpressionEditor 。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:
在网站项目中,将名为 Strings 的新资源文件添加到 App_GlobalResources 文件夹。In a Web site project, add a new resource file named Strings.resx to the App_GlobalResources folder.
将名为的字符串添加
myLinkText到字符串 .resx 资源文件中,并将值设置为控件的文本 HyperLink 。Add a string namedmyLinkTextto the Strings.resx resource file, and set the value to the text for a HyperLink control. 例如,将myLinkText字符串值设置为This is a link。For example, set themyLinkTextstring value toThis is a link.在 ASP.NET 网页中,添加一个 HyperLink 控件。In an ASP.NET Web page, add a HyperLink control.
在控件的属性网格中
Hyperlink,单击 " 表达式",然后单击省略号按钮 " (..." ) 以显示 "表达式绑定" 对话框。In the property grid for theHyperlinkcontrol, click Expressions, and click the ellipsis button (...) to display the expression binding dialog box.选择
Text控件的属性,并将 expression 类型 设置为Resources表达式类型。Select theTextproperty of a control, and set Expression Type to theResourcesexpression type. 可视化设计器显示对象定义的资源表达式属性 ResourceExpressionEditorSheet 。The visual designer displays the resource expression properties defined by the ResourceExpressionEditorSheet object.设置 表达式属性 ,如下所示:Set the Expression Properties as follows:
将 ClassKey 设置为
Strings,即已编译的字符串 .resx 资源文件的类名称。Set ClassKey toStrings, the class name for the compiled Strings.resx resource file.将 ResourceKey 设置为
myLinkText,即字符串 .resx 中的字符串名称。Set ResourceKey tomyLinkText, 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>
注解
可视化设计器将 ResourceExpressionEditor 类与类结合使用 ResourceExpressionEditorSheet ,以选择资源引用表达式的各个属性,并将所选的资源表达式属性值合并为资源表达式。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.
ResourceKey必须在资源表达式中指定属性; 此属性将为资源值编制索引。The 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() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |