首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ASP.NET主题和Skins应该包含空格吗?

ASP.NET主题和Skins应该包含空格吗?
EN

Stack Overflow用户
提问于 2014-01-16 08:00:01
回答 2查看 166关注 0票数 1

我正在创建一个带有几个高对比主题的ASP站点。我已经创建了其他网站的主题,但这是第一个不会改变,当一个新的主题被选择。我有一个理论,主题和皮肤文件不应该包含在文件夹或文件名中的空格,但我不确定。任何建议都会很棒。这是我的下拉列表:

代码语言:javascript
复制
<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>

下面是母版页后面的代码:

代码语言:javascript
复制
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
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-06-20 21:28:02

这真的不重要。当我第一次问这个问题时,我忘了在下拉列表和复选框AutoPostBack="True"中添加一个重要的属性。自从我决定再次尝试编写可逆主题以来,我在主题名称方面还没有遇到任何麻烦。

票数 1
EN

Stack Overflow用户

发布于 2014-01-16 10:22:17

它会使您从未将新选定的主题设置为代码中的页。试着做这样的事:

代码语言:javascript
复制
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
        ' Set the new theme
        Page.Theme=DDL_SwitchTheme.SelectedValue

        Response.Cookies.Add(preferredTheme)
        Response.Redirect(Request.Url.ToString())
    End Sub
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21156265

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档