2010-09-16 68 views
0

這裏我想爲主頁面設置主題,但我不知道如何去做,所以請告訴我一些解決方案。 所有我想從後面的代碼做。 謝謝大家。在asp.net中應用主題

回答

1

How to: Apply ASP.NET Themes Programmatically

protected void Page_PreInit(object sender, EventArgs e) 
{ 
    switch (Request.QueryString["theme"]) 
    { 
     case "Blue": 
      Page.Theme = "BlueTheme"; 
      break; 
     case "Pink": 
      Page.Theme = "PinkTheme"; 
      break; 
    } 
} 
0

您可以使用Page_PreInit方法執行此操作。查詢here瞭解更多詳情。

您可以通過設置Page.Theme屬性來設置主題。例如,Page.Theme = "MyTheme"

+0

雅,我知道,但我怎麼設置呢? – Abhishek 2010-09-16 10:24:36

+0

this this.Page.Theme =「collection」; 「 – Abhishek 2010-09-16 10:25:02

+0

還是別的? – Abhishek 2010-09-16 10:25:21

0

VB

Protected Sub Page_PreInit(ByVal sender As Object, _ 
     ByVal e As System.EventArgs) Handles Me.PreInit 

     Page.Theme = "ThemeName" 

End Sub 

C#

protected void Page_PreInit(object sender, EventArgs e) 
{ 
    Page.Theme = "ThemeName"; 
}