Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# <;asp.net菜单控件>;所选项目样式表无法应用_C#_Html_Asp.net_Asp.net Mvc - Fatal编程技术网

C# <;asp.net菜单控件>;所选项目样式表无法应用

C# <;asp.net菜单控件>;所选项目样式表无法应用,c#,html,asp.net,asp.net-mvc,C#,Html,Asp.net,Asp.net Mvc,我面临一个奇怪的问题,无法将样式表添加为选定项: 我的html如下所示: <asp:Menu ID="Menu2" runat="server" Orientation="Horizontal" DisappearAfter="10" CssClass="art-hmenu" DataSourceID="XmlDataSource1" IncludeStyleBlock="false" StaticEnableDefaultPopOu

我面临一个奇怪的问题,无法将样式表添加为选定项:

我的html如下所示:

<asp:Menu ID="Menu2"
    runat="server"
    Orientation="Horizontal"
    DisappearAfter="10"
    CssClass="art-hmenu"
    DataSourceID="XmlDataSource1"
    IncludeStyleBlock="false"
    StaticEnableDefaultPopOutImage="False">
    <StaticSelectedStyle CssClass="selected"/>
    <DataBindings>
        <asp:MenuItemBinding DataMember="Item" NavigateUrlField="Url" TextField="Text" />
    </DataBindings>
</asp:Menu>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" />
  public partial class Menu : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SelectRighMenuItem();
        }
    }

    /// <summary>
    /// 
    /// </summary>
    void SelectRighMenuItem()
    {
        string appDataPath = HttpContext.Current.Server.MapPath("~/App_Data");
        this.XmlDataSource1.DataFile = appDataPath + "\\" + GetRole() + "_menu.xml";
        this.XmlDataSource1.XPath = @"/Items/Item";
    }

    protected string GetRole()
    {
        string role = string.Empty;
        role = Session["Roles"].ToString();
        return role;
    }

}
但这是行不通的

我还尝试设置StaticSelectedStyle!!但也不起作用

我使用的样式表是:

/* menu structure */

ul.art-hmenu a, ul.art-hmenu a:link, ul.art-hmenu a:visited, ul.art-hmenu a:hover {
    outline: none;
    position: relative;
    z-index: 11;
}


.active {

            color:green;
    background-color:yellow;
        }

ul.art-hmenu, ul.art-hmenu ul {
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    list-style-type: none;
}

    ul.art-hmenu li {
        margin: 0;
        padding: 0;
        border: 0;
        display: block;
        float: left;
        position: relative;
        z-index: 5;
        background: none;
    }

        ul.art-hmenu li:hover {
            z-index: 10000;
            white-space: normal;
        }

        ul.art-hmenu li li {
            float: none;
            width: auto;
        }

        ul.art-hmenu li:hover > ul {
            visibility: visible;
            top: 100%;
        }

        ul.art-hmenu li li:hover > ul {
            top: 0;
            left: 100%;
        }

    ul.art-hmenu:after, ul.art-hmenu ul:after {
        content: ".";
        height: 0;
        display: block;
        visibility: hidden;
        overflow: hidden;
        clear: both;
    }

    ul.art-hmenu, ul.art-hmenu ul {
        min-height: 0;
    }


        ul.art-hmenu ul {
            visibility: hidden;
            position: absolute;
            z-index: 10;
            left: 0;
            top: 0;
            background-image: url('images/spacer.gif');
            padding: 10px 30px 30px 30px;
            margin: -10px 0 0 -30px;
        }

            ul.art-hmenu ul.art-hmenu-left-to-right {
                right: auto;
                left: 0;
                margin: -10px 0 0 -30px;
            }

            ul.art-hmenu ul.art-hmenu-right-to-left {
                left: auto;
                right: 0;
                margin: -10px -30px 0 0;
            }

            ul.art-hmenu ul ul {
                padding: 30px 30px 30px 10px;
                margin: -30px 0 0 -10px;
                margin-left: -11px;
                z-index: -1;
            }

                ul.art-hmenu ul ul.art-hmenu-left-to-right {
                    right: auto;
                    left: 0;
                    padding: 30px 30px 30px 10px;
                    margin: -30px 0 0 -10px;
                    margin-left: -11px;
                }

                ul.art-hmenu ul ul.art-hmenu-right-to-left {
                    left: auto;
                    right: 0;
                    padding: 30px 10px 30px 30px;
                    margin: -30px -10px 0 0;
                    margin-right: -11px;
                }

        ul.art-hmenu li li:hover > ul.art-hmenu-left-to-right {
            right: auto;
            left: 100%;
        }

        ul.art-hmenu li li:hover > ul.art-hmenu-right-to-left {
            left: auto;
            right: 100%;
        }

ul.art-hmenu {
    position: relative;
    padding: 3px 3px 3px 3px;
    float: left;
}

/* end menu structure */

/* menu bar */

.art-nav {
    min-width: 700px;
    max-width: 1728px;
    margin: 0 auto;
    min-height: 36px;
    z-index: 100;
    margin: 0 0 -36px;
    width: auto;
    top: 214px;
}

    .art-nav:before, .art-nav:after {
        background-image: url('images/nav.png');
    }

    .art-nav:before {
        right: 0;
    }

    .art-nav:after {
        width: 0;
    }
/* end menu bar */
.art-nav-outer {
    position: absolute;
    width: 100%;
}

.art-nav-wrapper {
    position: relative;
    margin: 0 auto;
    width: auto;
}

.art-nav-inner {
    margin: 0 4px;
}

/* end Menu */

/* begin MenuItem */
ul.art-hmenu > li > a {
    position: relative;
    display: block;
    height: 30px;
    cursor: pointer;
    text-decoration: none;
    color: #D2E4EE;
    padding: 0 20px;
    line-height: 30px;
    text-align: center;
}

    ul.art-hmenu > li > a:before, ul.art-hmenu > li > a:after {
        position: absolute;
        display: block;
        content: ' ';
        top: 0;
        bottom: 0;
        z-index: -1;
        background-image: url('images/menuitem.png');
    }

    ul.art-hmenu > li > a:before {
        left: 0;
        right: 12px;
        background-position: top left;
    }

    ul.art-hmenu > li > a:after {
        width: 12px;
        right: 0;
        background-position: top right;
    }

.art-hmenu a, .art-hmenu a:link, .art-hmenu a:visited, .art-hmenu a:hover {
    text-align: left;
    text-decoration: none;
}

ul.art-hmenu > li > a.active:before {
    background-position: bottom left;
}

ul.art-hmenu > li > a.active:after {
    background-position: bottom right;
}

ul.art-hmenu > li > a.active {
    color: #000000;
}

ul.art-hmenu > li > a:hover:before, ul.art-hmenu > li:hover > a:before {
    background-position: center left;
}

ul.art-hmenu > li > a:hover:after, ul.art-hmenu > li:hover > a:after {
    background-position: center right;
}

ul.art-hmenu > li > a:hover, ul.art-hmenu > li:hover > a {
    color: #D9E0E8;
}

/* end MenuItem */

/* begin MenuSeparator */
ul.art-hmenu > li:before {
    position: absolute;
    display: block;
    content: ' ';
    top: 0;
    left: -13px;
    width: 13px;
    height: 30px;
    background: url('images/menuseparator.png') center center no-repeat;
}

ul.art-hmenu > li {
    margin-left: 13px;
}

    ul.art-hmenu > li:first-child {
        margin-left: 0;
    }

        ul.art-hmenu > li:first-child:before {
            display: none;
        }
/* end MenuSeparator */

/* begin MenuSubItem */
.art-hmenu ul a {
    display: block;
    white-space: nowrap;
    height: 24px;
    background-image: url('images/subitem.png');
    background-position: left top;
    background-repeat: repeat-x;
    border-width: 1px;
    border-style: solid;
    border-top-width: 0;
    border-color: #99ADC2;
    min-width: 7em;
    text-align: left;
    text-decoration: none;
    line-height: 24px;
    color: #152B38;
    margin: 0;
    padding: 0 8px;
}

.art-hmenu ul > li:first-child > a {
    border-top-width: 1px;
}

.art-hmenu ul a:link , .art-hmenu ul a:visited, .art-hmenu ul a:hover, .art-hmenu ul a:active {
    text-align: left;
    text-decoration: none;
    line-height: 24px;
    color: #152B38;
    margin: 0;
    padding: 0 8px;
}
.art-hmenu ul a:link .highlighted {
    color: #152B38;
    background-color: #fff;
}

.art-hmenu ul li a:hover {
    color: #000000;
    background-position: left bottom;
    border-color: #A76801;
    border-top-width: 1px !important;
}

.art-hmenu ul li a.art-hmenu-before-hovered {
    border-bottom-width: 0 !important;
}

.art-hmenu ul li:hover > a {
    color: #000000;
    background-position: left bottom;
    border-color: #A76801;
    border-top-width: 1px !important;
}

.art-hmenu ul li:hover > a.selected
{
    color: #000000;
    background-position: left bottom;
    border-color: #A76801;
    border-top-width: 1px !important;
}

.SelectedMenuItem
{
    color: #000000;
    background-position: left bottom;
    border-color: #A76801;
    border-top-width: 1px !important;
}

/* end MenuSubItem */

艺术华萌来自哪里?我没有在标记中看到它?使用chrome inspect元素查看页面上呈现的实际结构,这可能有助于我更新问题!通过Chrome控制台检查页面上没有javascript错误(希望您有Chrome!),如果没有,则尝试使用$(“.art hmenu”)。单击(function(){alert(“Hello click”);});是的,我检查了所有内容,更多关于我所做工作的更新如下:
/* menu structure */

ul.art-hmenu a, ul.art-hmenu a:link, ul.art-hmenu a:visited, ul.art-hmenu a:hover {
    outline: none;
    position: relative;
    z-index: 11;
}


.active {

            color:green;
    background-color:yellow;
        }

ul.art-hmenu, ul.art-hmenu ul {
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    list-style-type: none;
}

    ul.art-hmenu li {
        margin: 0;
        padding: 0;
        border: 0;
        display: block;
        float: left;
        position: relative;
        z-index: 5;
        background: none;
    }

        ul.art-hmenu li:hover {
            z-index: 10000;
            white-space: normal;
        }

        ul.art-hmenu li li {
            float: none;
            width: auto;
        }

        ul.art-hmenu li:hover > ul {
            visibility: visible;
            top: 100%;
        }

        ul.art-hmenu li li:hover > ul {
            top: 0;
            left: 100%;
        }

    ul.art-hmenu:after, ul.art-hmenu ul:after {
        content: ".";
        height: 0;
        display: block;
        visibility: hidden;
        overflow: hidden;
        clear: both;
    }

    ul.art-hmenu, ul.art-hmenu ul {
        min-height: 0;
    }


        ul.art-hmenu ul {
            visibility: hidden;
            position: absolute;
            z-index: 10;
            left: 0;
            top: 0;
            background-image: url('images/spacer.gif');
            padding: 10px 30px 30px 30px;
            margin: -10px 0 0 -30px;
        }

            ul.art-hmenu ul.art-hmenu-left-to-right {
                right: auto;
                left: 0;
                margin: -10px 0 0 -30px;
            }

            ul.art-hmenu ul.art-hmenu-right-to-left {
                left: auto;
                right: 0;
                margin: -10px -30px 0 0;
            }

            ul.art-hmenu ul ul {
                padding: 30px 30px 30px 10px;
                margin: -30px 0 0 -10px;
                margin-left: -11px;
                z-index: -1;
            }

                ul.art-hmenu ul ul.art-hmenu-left-to-right {
                    right: auto;
                    left: 0;
                    padding: 30px 30px 30px 10px;
                    margin: -30px 0 0 -10px;
                    margin-left: -11px;
                }

                ul.art-hmenu ul ul.art-hmenu-right-to-left {
                    left: auto;
                    right: 0;
                    padding: 30px 10px 30px 30px;
                    margin: -30px -10px 0 0;
                    margin-right: -11px;
                }

        ul.art-hmenu li li:hover > ul.art-hmenu-left-to-right {
            right: auto;
            left: 100%;
        }

        ul.art-hmenu li li:hover > ul.art-hmenu-right-to-left {
            left: auto;
            right: 100%;
        }

ul.art-hmenu {
    position: relative;
    padding: 3px 3px 3px 3px;
    float: left;
}

/* end menu structure */

/* menu bar */

.art-nav {
    min-width: 700px;
    max-width: 1728px;
    margin: 0 auto;
    min-height: 36px;
    z-index: 100;
    margin: 0 0 -36px;
    width: auto;
    top: 214px;
}

    .art-nav:before, .art-nav:after {
        background-image: url('images/nav.png');
    }

    .art-nav:before {
        right: 0;
    }

    .art-nav:after {
        width: 0;
    }
/* end menu bar */
.art-nav-outer {
    position: absolute;
    width: 100%;
}

.art-nav-wrapper {
    position: relative;
    margin: 0 auto;
    width: auto;
}

.art-nav-inner {
    margin: 0 4px;
}

/* end Menu */

/* begin MenuItem */
ul.art-hmenu > li > a {
    position: relative;
    display: block;
    height: 30px;
    cursor: pointer;
    text-decoration: none;
    color: #D2E4EE;
    padding: 0 20px;
    line-height: 30px;
    text-align: center;
}

    ul.art-hmenu > li > a:before, ul.art-hmenu > li > a:after {
        position: absolute;
        display: block;
        content: ' ';
        top: 0;
        bottom: 0;
        z-index: -1;
        background-image: url('images/menuitem.png');
    }

    ul.art-hmenu > li > a:before {
        left: 0;
        right: 12px;
        background-position: top left;
    }

    ul.art-hmenu > li > a:after {
        width: 12px;
        right: 0;
        background-position: top right;
    }

.art-hmenu a, .art-hmenu a:link, .art-hmenu a:visited, .art-hmenu a:hover {
    text-align: left;
    text-decoration: none;
}

ul.art-hmenu > li > a.active:before {
    background-position: bottom left;
}

ul.art-hmenu > li > a.active:after {
    background-position: bottom right;
}

ul.art-hmenu > li > a.active {
    color: #000000;
}

ul.art-hmenu > li > a:hover:before, ul.art-hmenu > li:hover > a:before {
    background-position: center left;
}

ul.art-hmenu > li > a:hover:after, ul.art-hmenu > li:hover > a:after {
    background-position: center right;
}

ul.art-hmenu > li > a:hover, ul.art-hmenu > li:hover > a {
    color: #D9E0E8;
}

/* end MenuItem */

/* begin MenuSeparator */
ul.art-hmenu > li:before {
    position: absolute;
    display: block;
    content: ' ';
    top: 0;
    left: -13px;
    width: 13px;
    height: 30px;
    background: url('images/menuseparator.png') center center no-repeat;
}

ul.art-hmenu > li {
    margin-left: 13px;
}

    ul.art-hmenu > li:first-child {
        margin-left: 0;
    }

        ul.art-hmenu > li:first-child:before {
            display: none;
        }
/* end MenuSeparator */

/* begin MenuSubItem */
.art-hmenu ul a {
    display: block;
    white-space: nowrap;
    height: 24px;
    background-image: url('images/subitem.png');
    background-position: left top;
    background-repeat: repeat-x;
    border-width: 1px;
    border-style: solid;
    border-top-width: 0;
    border-color: #99ADC2;
    min-width: 7em;
    text-align: left;
    text-decoration: none;
    line-height: 24px;
    color: #152B38;
    margin: 0;
    padding: 0 8px;
}

.art-hmenu ul > li:first-child > a {
    border-top-width: 1px;
}

.art-hmenu ul a:link , .art-hmenu ul a:visited, .art-hmenu ul a:hover, .art-hmenu ul a:active {
    text-align: left;
    text-decoration: none;
    line-height: 24px;
    color: #152B38;
    margin: 0;
    padding: 0 8px;
}
.art-hmenu ul a:link .highlighted {
    color: #152B38;
    background-color: #fff;
}

.art-hmenu ul li a:hover {
    color: #000000;
    background-position: left bottom;
    border-color: #A76801;
    border-top-width: 1px !important;
}

.art-hmenu ul li a.art-hmenu-before-hovered {
    border-bottom-width: 0 !important;
}

.art-hmenu ul li:hover > a {
    color: #000000;
    background-position: left bottom;
    border-color: #A76801;
    border-top-width: 1px !important;
}

.art-hmenu ul li:hover > a.selected
{
    color: #000000;
    background-position: left bottom;
    border-color: #A76801;
    border-top-width: 1px !important;
}

.SelectedMenuItem
{
    color: #000000;
    background-position: left bottom;
    border-color: #A76801;
    border-top-width: 1px !important;
}

/* end MenuSubItem */