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. InvalidOperationException MasterPageFile PreInit屬性只能PreInit在事件中設定; 在事件會擲回例外狀況之後,嘗試設定屬性。 MasterPageFileThe 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. 如果屬性無效,則會在頁面生命週期稍後HttpException擲回類型的例外狀況,但在PreInit事件中設定屬性時,不會擲回任何例外狀況。 MasterPageFileIf 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.

適用於

另請參閱