Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ResourceExpressionEditor Class

Provides properties and methods for evaluating and editing a resource expression at design time.

System.Object
  System.Web.UI.Design.ExpressionEditor
    System.Web.UI.Design.ResourceExpressionEditor

Namespace:  System.Web.UI.Design
Assembly:  System.Design (in System.Design.dll)
public class ResourceExpressionEditor : ExpressionEditor

The ResourceExpressionEditor type exposes the following members.

  NameDescription
Public methodResourceExpressionEditorInitializes a new instance of a ResourceExpressionEditor 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 a resource expression 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 a resource expression editor sheet that is initialized with the input expression string and service provider implementation. (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 ResourceExpressionEditor class derives from the ExpressionEditor class and provides an implementation for evaluating and associating a resource reference with a control property at design time. For example, you can bind the value of a control property to the resource expression Resources:submitText, which indicates that the control property value is set using the resource named submitText.

A visual designer host, such as Visual Studio 2005, uses the ResourceExpressionEditor class to specify a resource class, key, and designer default value for a resource expression, and then evaluate the selected resource expression for design-time rendering.

When you browse 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 Resources expression prefix in the list, the visual designer uses the ResourceExpressionEditor methods to set, evaluate, and convert the expression based on the resource expression syntax. The visual designer uses the evaluated expression result to assign control property values that are rendered on the design surface.

The base ExpressionBuilder.ExpressionPrefix property for a ResourceExpressionBuilder returns the string Resources. The ResourceExpressionBuilder class is associated with the expression prefix Resources and the ResourceExpressionEditor implementation.

The EvaluateExpression method evaluates an input resource expression. The GetExpressionEditorSheet method returns the ExpressionEditorSheet implementation that is used to select the resource name, class, and designer default value, and to form a resource expression from the selected resource values.

The following code example demonstrates how to bind the Text property of a HyperLink control to a resource expression using the ResourceExpressionEditor class.

  1. In a Web Forms project, add a new resource file named Strings.resx to the App_LocalResources directory.

  2. Add a string named myLinkText to the Strings.resx resource file, and then set the value to the text for a HyperLink control.

    For example, set the myLinkText string value to This is a good link.

  3. In a Web Forms page, add a HyperLink control.

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

    The <Hyperlinkname> Expressions dialog box appears.

  5. Under Bindable properties, click Text, and then in the Expression type list, enter Resources.

    The resource expression properties that are defined by the ResourceExpressionEditorSheet class appear.

  6. Under Expression Properties set ClassName to Strings, which is the class name for the compiled Strings.resx resource file and set ResourceKey to myLinkText, which is the string name in Strings.resx.

The visual designer uses the ResourceExpressionEditor to assign the resource expression for the Text property. The following .aspx source shows an example of a property value that is set by 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>
<FileName>ControlsUsingExpressions.aspx</FileName>
<RelevantItems>
    <Reference>System.Web.UI.Design.ResourceExpressionEditor</Reference>
</RelevantItems>

.NET Framework

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

Windows Phone 8.1, Windows Phone 8, 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.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.