Я создаю сайт ASP с несколькими высококонтрастными темами. Я создал другие сайты с темами, но это первый, который не изменится при выборе новой темы. У меня есть теория, что файлы темы и скина не должны содержать пробелов в именах папок или файлов, но я не уверен. Любые советы были бы замечательными. Вот мой выпадающий список:Должны ли ASP.NET темы и скины содержать пространства?
<asp:DropDownList ID="DDL_SwitchTheme" runat="server" CssClass="BigText">
<asp:ListItem Disabled="true" style="color: Silver;">High Contrast Themes</asp:ListItem>
<asp:ListItem style="color: Black; background-color: White; font-weight: bolder;">Black and White</asp:ListItem>
<asp:ListItem style="color: White; background-color: Black; font-weight: bolder;">Black and White Reverse</asp:ListItem>
<asp:ListItem style="color: Yellow; background-color: Black; font-weight: bolder;"
Value="Black and Yellow">Yellow and Black</asp:ListItem>
<asp:ListItem style="color: Black; background-color: Yellow; font-weight: bolder;"
Value="Black and Yellow">Yellow and Black Reverse</asp:ListItem>
<asp:ListItem style="color: Yellow; background-color: Blue; font-weight: bolder;"
Value="Blue and Yellow">Blue and Yellow</asp:ListItem>
<asp:ListItem style="color: Blue; background-color: Yellow; font-weight: bolder;"
Value="Blue and Yellow">Blue and Yellow Reverse</asp:ListItem>
...
...
</asp:DropDownList>
А вот код позади от главной страницы:
Partial Class Site
Inherits System.Web.UI.MasterPage
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim pageColor As String = ""
If Not Page.IsPostBack Then
Dim selectedTheme As String = Page.Theme
Dim preferredTheme As HttpCookie = Request.Cookies.Get("PreferredTheme")
If preferredTheme IsNot Nothing Then
selectedTheme = preferredTheme.Value
End If
If Not String.IsNullOrEmpty(selectedTheme) AndAlso DDL_SwitchTheme.Items.FindByValue(selectedTheme) IsNot Nothing Then
DDL_SwitchTheme.Items.FindByValue(selectedTheme).Selected = True
End If
End If
End Sub
Protected Sub DDL_SwitchTheme_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles DDL_SwitchTheme.SelectedIndexChanged
Dim preferredTheme As HttpCookie = New HttpCookie("PreferredTheme")
preferredTheme.Expires = DateTime.Now.AddDays(7)
preferredTheme.Value = DDL_SwitchTheme.SelectedValue
Response.Cookies.Add(preferredTheme)
Response.Redirect(Request.Url.ToString())
End Sub
End Class
Это потрясающая идея, но она уже реализована в классе BasePage. Я воспринял эту тему, меняя код прямо с Wrox's Beginning ASP.NET 4 в C# и VB, и до сих пор он никогда не подводил меня. Я попытался поместить метод в этот комментарий, но он не сработал, так что это главный вопрос. Жаль, что я не ответил раньше; У меня есть другой проект веб-сайта, над которым я работаю, это намного лучше. :) – Shortstuff81000