共用方式為


ResourceExpressionEditor 類別

定義

提供在設計時評估與編輯資源表達式的屬性與方法。

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

範例

以下程式碼範例示範如何使用 類別ResourceExpressionEditor將控制項的屬性HyperLink綁定Text到資源表達式。

  1. 在 Web Forms 專案中,新增一個名為 Strings.resx 的資源檔案到 App_LocalResources 目錄。

  2. 在 Strings.resx 資源檔中加入一個名為 myLinkText 的字串,然後將該值設為控制項的文字 HyperLink

    例如,將字串值設 myLinkTextThis is a good link

  3. 在網頁表單頁面中,新增一個 HyperLink 控制項。

  4. 在屬性中 Hyperlink ,點選 「表達式」,然後點擊省略號按鈕(...)。

    <Hyperlinkname>表達式」對話框會出現。

  5. 可綁定屬性中,點選 「文字」,然後在 表達式類型 列表中輸入 「資源」。

    由類別定義 ResourceExpressionEditorSheet 的資源運算式屬性會出現。

  6. 表達式屬性 中,將 ClassName為 Strings,這是已編譯的 Strings.resx 資源檔的類別名稱,並將 ResourceKey 設為 myLinkText,也就是 Strings.resx 中的字串名稱。

視覺設計師會使用 來 ResourceExpressionEditor 指派屬性的 Text 資源表達式。 以下.aspx來源展示了一個透過資源運算式設定的屬性值範例。

<!-- 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 類別源自該 ExpressionEditor 類別,並提供一種實作,用於在設計時評估並關聯資源參考與控制屬性。 例如,你可以將控制屬性的值綁定到資源運算式 ,該表示 Resources:submitText控制屬性的值是用名為 submitText的資源設定的。

視覺設計器主機,如 Visual Studio 2005,會使用該 ResourceExpressionEditor 類別指定資源類別、鍵值及設計者預設值,並評估所選資源表達式以進行設計時渲染。

當你在 Expressions 設計時屬性網格中瀏覽控制項屬性時,視覺化設計器會顯示一個對話框,用來設定表達式,提供該控制屬性的執行時間值。 你可以根據表達式前綴清單選擇表達式類型。 當你在清單中選擇 Resources 表達式前綴時,視覺設計器會根據資源表達式語法,使用 ResourceExpressionEditor 這些方法來設定、評估並轉換表達式。 視覺設計師會利用評估後的表達式結果來指派控制屬性值,這些屬性會被渲染在設計表面上。

a ResourceExpressionBuilder 的基底ExpressionBuilder.ExpressionPrefix性質回傳字串 Resources。 類別ResourceExpressionBuilder與表達式前綴ResourcesResourceExpressionEditor及實作相關聯。

EvaluateExpression 方法評估輸入資源表達式。 該 GetExpressionEditorSheet 方法回傳 ExpressionEditorSheet 用於選擇資源名稱、類別及設計預設值,並從所選資源值組成資源表達式的實作。

建構函式

名稱 Description
ResourceExpressionEditor()

初始化一個新的類別實例 ResourceExpressionEditor

屬性

名稱 Description
ExpressionPrefix

取得表達式前綴,用以識別表達式編輯器實作所支援的表達式字串。

(繼承來源 ExpressionEditor)

方法

名稱 Description
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
EvaluateExpression(String, Object, Type, IServiceProvider)

評估資源表達式並提供控制屬性的設計時值。

GetExpressionEditorSheet(String, IServiceProvider)

回傳一個資源表達式編輯器表,該表單以輸入表達字串及服務提供者實作初始化。

GetHashCode()

做為預設哈希函式。

(繼承來源 Object)
GetType()

取得目前實例的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)

適用於

另請參閱