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 已发生后设置 PreInit 属性。An 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 InvalidOperationException必须在PreInit事件之前设置属性;在事件之后设置属性将导致异常。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.

适用于

另请参阅