ResourceExpressionBuilder 類別

定義

提供程式碼給頁面剖析器,以指派控制項上的屬性值。

public ref class ResourceExpressionBuilder : System::Web::Compilation::ExpressionBuilder
public class ResourceExpressionBuilder : System.Web.Compilation.ExpressionBuilder
type ResourceExpressionBuilder = class
    inherit ExpressionBuilder
Public Class ResourceExpressionBuilder
Inherits ExpressionBuilder
繼承
ResourceExpressionBuilder

範例

下列程式碼範例會從資源檔擷取預設貨幣。

<%@ Page Language="C#" UICulture="auto" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Sales Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        All prices listed in 
        <asp:Literal ID="Literal1" runat="server" 
        Text="<%$ Resources: Financial, Currency %>" />.
    </div>
    </form>
</body>
</html>
<%@ Page Language="VB" UICulture="auto" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Sales Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        All prices listed in 
        <asp:Literal ID="Literal1" runat="server" 
        Text="<%$ Resources: Financial, Currency %>" />.
    </div>
    </form>
</body>
</html>

此程式碼會從App_GlobalResources目錄中名為 Financial.resx 的資源檔讀取下列值。

<data name="Currency"><value xml:space="preserve">US dollars</value></data>  

備註

類別 ResourceExpressionBuilder 會建立程式碼,以在執行頁面時擷取資源值。 資源檔通常包含針對特定語言或文化特性當地語系化的資訊。

資源運算式會採用頁面內的表單 <%$ Resources: ClassKey, ResourceKey %> 。 冒號之前的運算式部分, (:) 指定要使用的運算式產生器類型,而冒號之後的部分表示類別名稱和資源索引鍵。 上述運算式會從名為 ClassKey.resx 的檔案擷取下列值:

<data name="ResourceKey"><value xml:space="preserve">Hello!</value></data>  

當頁面剖析器遇到具有前置詞的 Resources 運算式時,它會建立 類別的 ResourceExpressionBuilder 實例。 類別 ResourceExpressionBuilder 會評估運算式,或產生程式碼,以在執行頁面時傳回運算式的值。

如果在將編譯的頁面中遇到運算式, ResourceExpressionBuilder 物件會產生程式碼,從資源檔擷取指定的值。 如果在不會編譯的頁面中遇到運算式,當 ResourceExpressionBuilder 剖析頁面時,物件會從資源檔傳回值。

建構函式

ResourceExpressionBuilder()

初始化 ResourceExpressionBuilder 類別的新執行個體。

屬性

SupportsEvaluate

傳回值,指出是否可在使用無編譯功能的頁面中評估運算式。

方法

Equals(Object)

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

(繼承來源 Object)
EvaluateExpression(Object, BoundPropertyEntry, Object, ExpressionBuilderContext)

從資源檔傳回值。

GetCodeExpression(BoundPropertyEntry, Object, ExpressionBuilderContext)

傳回要在頁面執行期間評估的程式碼運算式。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ParseExpression(String)

傳回物件,表示剖析的運算式。

ParseExpression(String, Type, ExpressionBuilderContext)

傳回物件,表示剖析的運算式。

ToString()

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

(繼承來源 Object)

適用於

另請參閱