Page.MasterPageFile Page.MasterPageFile Page.MasterPageFile Page.MasterPageFile Property

定義

取得或設定主版頁面的虛擬路徑。Gets or sets the virtual path of the master page.

public:
 virtual property System::String ^ MasterPageFile { System::String ^ get(); void set(System::String ^ value); };
public virtual string MasterPageFile { get; set; }
member this.MasterPageFile : string with get, set
Public Overridable Property MasterPageFile As String

屬性值

主版頁面的虛擬路徑。The virtual path of the master page.

例外狀況

MasterPageFile 事件完成之後,會設定 PreInit 屬性。The MasterPageFile property is set after the PreInit event is complete.

MasterPageFile 屬性中指定的檔案不存在。The file specified in the MasterPageFile property does not exist.

-或--or- 頁面沒有 Content 控制項當做最上層控制項。The page does not have a Content control as the top level control.

備註

MasterPageFile屬性是此頁面相關聯的主版頁面檔案虛擬路徑 (來自應用程式的根目錄)。The MasterPageFile property is a virtual path (from the root of the application) of the master page file associated with this page. MasterPageFile屬性可以設定只有在PreInit事件,嘗試設定MasterPageFile屬性後的PreInit事件將會擲回InvalidOperationException例外狀況。The MasterPageFile property can be set only in the PreInit event; attempting to set the MasterPageFile property after the PreInit event will throw an InvalidOperationException exception. 如果MasterPageFile屬性不是有效的類型的例外狀況HttpException稍後在頁面生命週期,會擲回但中設定屬性時,會擲回任何例外狀況PreInit事件。If the MasterPageFile property is not valid, an exception of type HttpException is thrown later in the page life cycle, but no exception is thrown when the property is set in the PreInit event.

頁面具有MasterPageFile屬性集是內容的頁面,並因此可以包含只有最上層控制項Content控制項。Pages that have the MasterPageFile property set are content pages, and therefore can contain only top-level controls that are Content controls.

適用於

另請參閱