Page.Theme Page.Theme Page.Theme Page.Theme Property

定義

取得或設定頁面主題的名稱。Gets or sets the name of the page theme.

public:
 virtual property System::String ^ Theme { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Browsable(false)]
public virtual string Theme { get; set; }
member this.Theme : string with get, set
Public Overridable Property Theme As String

屬性值

頁面主題的名稱。The name of the page theme.

例外狀況

嘗試在發生 Theme 事件之後設定 PreInitAn attempt was made to set Theme after the PreInit event has occurred.

Theme 是設為無效的主題名稱。Theme is set to an invalid theme name.

範例

下列程式碼範例會將Theme屬性設定為查詢字串中傳遞的名稱。The following code example sets the Theme property to a name passed in the query string.

void Page_PreInit(object sender, EventArgs e)
{
  // Get the theme name from a QueryString variable
  string ThemeName;
  ThemeName = Request.QueryString["thename"];
  if (ThemeName != null)
  {
    Page.Theme = ThemeName;
  }
}
Public Sub Page_PreInit(ByVal Sender As Object, ByVal e As EventArgs)
      
  ' Get the theme name from a QueryString variable
  Dim ThemeName As String
  ThemeName = Request.QueryString("thename")
  If ThemeName <> Nothing Then
    Page.Theme = ThemeName
  End If
End Sub

備註

Theme屬性會設定用於頁面的主題名稱。The Theme property sets the name of the theme used for the page. 如果您想要讓頁面上的設定優先于主題中的設定,請使用StyleSheetTheme屬性。If you want the settings on the page to take precedence over the settings in the theme, use the StyleSheetTheme property. 如需詳細資訊,請參閱ASP.NET 主題和外觀For more information, see ASP.NET Themes and Skins.

PreInit Theme PreInit屬性必須在事件之前設定; 在事件之後設定屬性會造成InvalidOperationException例外狀況。 ThemeThe Theme property must be set prior to the PreInit event; setting the Theme property after the PreInit event will cause an InvalidOperationException exception.

指定的主題必須以應用程式或全域主題的形式存在。The specified theme must exist as either an application or a global theme. 如果主題不存在, HttpException則會擲回例外狀況。If the theme does not exist, an HttpException exception is thrown.

適用於

另請參閱