Page.AspCompatMode Page.AspCompatMode Page.AspCompatMode Page.AspCompatMode Property

定義

設定數值,指出頁面是否可以在單一執行緒 Apartment (STA) 執行緒上執行。Sets a value indicating whether the page can be executed on a single-threaded apartment (STA) thread.

protected:
 property bool AspCompatMode { bool get(); void set(bool value); };
protected bool AspCompatMode { get; set; }
member this.AspCompatMode : bool with get, set
Protected Property AspCompatMode As Boolean

屬性值

如果頁面支援 Active Server Pages (ASP) 程式碼,則為 true,否則為 falsetrue if the page supports Active Server Pages (ASP) code; otherwise, false. 預設為 falseThe default is false.

備註

當設定為true時,這個屬性允許在單一執行緒的單元(STA)執行緒上執行頁面。When set to true, this property allows the page to be executed on a single-threaded apartment (STA) thread. 這可讓頁面呼叫 STA 元件,例如以 Visual Basic 6.0 開發的元件。This allows the page to call STA components, such as components developed with Visual Basic 6.0. 將這個屬性設定true為,也可以讓頁面呼叫需要存取非受控 ASP 內建物件的 com + 元件。Setting this property to true also allows the page to call COM+ components that require access to the unmanaged ASP built-in objects. 這些可以透過 ASP ObjectContext物件OnStartPage或方法來存取。These are accessible through the ASP ObjectContext object or the OnStartPage method.

在大部分的情況下,請勿在程式碼中設定此屬性。In most circumstances, do not set this property in code. 使用 .aspx 檔案中true@ Page指示詞,將屬性設定為。aspcompatSet the aspcompat attribute to true using the @ Page directive in the .aspx file. 當要求頁面時,動態產生的類別會設定屬性。When the page is requested, the dynamically generated class sets the property.

適用於