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.

Theme屬性必須設定之前PreInit事件; 設定Theme屬性後的PreInit事件會導致InvalidOperationException例外狀況。The 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.

適用於

另請參閱