編譯之 expressionBuilders 的 add 項目 (ASP.NET 設定結構描述)

將運算式產生器的參考加入集合。

這個項目是 .NET Framework 2.0 版中新增的項目。

<add
   expressionPrefix = "prefix" 
   type = "type" 
/>

屬性和項目

下列章節會說明屬性、子項目和父項目。

屬性

屬性

描述

expressionPrefix

必要的 String 屬性。

指定運算式的前置詞。 這個字串是 .aspx 網頁中顯示的運算式左邊,例如:

<asp:Label ID="Label1" runat="server" Text="<%$ MyCustomExpression:Hello, world! %>" />

這是集合機碼。

預設為空字串 ("")。

type

必要的 String 屬性。

指定處理這個運算式的運算式產生器類別名稱。 它可以是衍生自 ExpressionBuilder 類別的自訂類別。

預設為空字串 ("")。

子項目

無。

父項目

項目

描述

configuration

指定 Common Language Runtime 和 .NET Framework 應用程式所使用之每個組態檔中的根項目 (Root Element)。

system.web

指定 ASP.NET 組態區段的根項目。

compilation

設定 ASP.NET 用來編譯應用程式的所有編譯設定。

expressionBuilders

定義編譯期間所要使用的資源字串集合。 資源字串會使前置詞與運算式產生器產生關聯。

這個項目是 .NET Framework 2.0 版中新增的項目。

備註

add 項目會將運算式產生器的參考加入至集合。

expressionBuilders 項目會定義編譯期間所要使用的資源字串集合。 資源字串會使前置詞與運算式產生器產生關聯。

當頁面剖析器 (Parser) 在以 <%$ %> 字串分隔的.aspx 頁面中發現運算式時,剖析器便會依據字串中的前置詞為該運算式建立運算式產生器。 前置詞是位在冒號 (:) 左方的字串部分。 例如,在發現 <%$ ConnectionStrings:MessageDB %> 字串時,剖析器就會建立 ConnectionStringsExpressionBuilder 物件。 如需詳細資訊,請參閱 ExpressionBuilder

預設組態

下列預設 expressionBuilders 項目不會明確地設定在 Machine.config 檔案或根 Web.config 檔案中。 然而,應用程式傳回的是預設組態。 項目會加入根 Web.config 檔的 expressionBuilders 集合。

<expressionBuilders>
   <clear />
</expressionBuilders>

下列的預設 expressionBuilders 項目是在根 Web.config 檔中設定。

<expressionBuilders>
   <add expressionPrefix="Resources" type="System.Web.Compilation.ResourceExpressionBuilder" />
   <add expressionPrefix="ConnectionStrings" type="System.Web.Compilation.ConnectionStringsExpressionBuilder" />
   <add expressionPrefix="AppSettings" type="System.Web.Compilation.AppSettingsExpressionBuilder" />
</expressionBuilders>

範例

下列程式碼範例示範如何在 Web.config 檔中註冊自訂運算式產生器。 自訂運算式產生器必須實作 ExpressionBuilder 抽象類別。

若要參考 .aspx 檔中的運算式,請使用下列語法:

<asp:Label ID="Label1" runat="server"

Text="<%$ MyCustomExpression:Hello, world! %>" />

<configuration>
    <system.web>
       <compilation>
          <expressionBuilders>
              <add expressionPrefix="MyCustomExpression"
               type="MyCustomExpressionBuilder"/>
          </expressionBuilders>
       </compilation>
    </system.web>
</configuration>

項目資訊

組態區段處理常式

CompilationSection

組態成員

Add

可設定的位置

Machine.config

根層次的 Web.config

應用程式層級的 Web.config

虛擬或實體目錄層級的 Web.config

需求

Microsoft Internet Information Services (IIS) 5.0、5.1 或 6.0 版

.NET Framework 2.0 版

Microsoft Visual Studio 2003 或 Visual Studio 2005

請參閱

工作

How to: Configure Specific Folders Using Location Settings

How to: Lock ASP.NET Configuration Settings

參考

編譯的 assemblies 項目 (ASP.NET 設定結構描述)

編譯之 expressionBuilders 的 remove 項目 (ASP.NET 設定結構描述)

編譯之 expressionBuilders 的 clear 項目 (ASP.NET 設定結構描述)

configuration 項目 (一般設定結構描述)

system.web 項目 (ASP.NET 設定結構描述)

compilation 項目 (ASP.NET 設定結構描述)

System.Configuration

System.Web.Configuration

CompilationSection

Add

概念

ASP.NET Compilation Model

ASP.NET Web Page Code Model

ASP.NET Configuration File Hierarchy

Securing Configuration

Configuration Inheritance

其他資源

一般組態設定 (ASP.NET)

ASP.NET 組態設定

Configuring ASP.NET Applications

ASP.NET Configuration Files

ASP.NET Configuration API