动态更改母版页中的菜单类 [英] Change Class of Menu in Master Page Dynamically

查看:53
本文介绍了动态更改母版页中的菜单类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从
子页面更改主页面中的菜单的CSS类名称?
我希望在任何儿童形式的菜单打开时将课程更改为有效,

How can i Change the CSS Class name of menu which is in Master page from Child Page? I want to change class to "active", when any of child form of menu is open,

是否有可用的C#或JavaScript代码?

Is any C# or JavaScript Code available?

谢谢

推荐答案

通过了解你的问题,我想你想要改变当页面发生变化时,li的类或菜单中使用的任何标记。

By understanding your question, i think you want to change the class of the li or whatever tag that is used in menu when the page changes.

请在主页page_load下添加以下c#代码。

Please add the following c# code under master page page_load .

 string thisURL = this.Page.GetType().Name.ToString();       
        switch (thisURL)
        {
            case "home_aspx":
                lihome.Attributes.Add("class", "Active");                
                break;
         case "support_aspx":
                lisupport.Attributes.Add("class", "Active");
                break;
         case "logout_aspx":
                lilogout.Attributes.Add("class", "Active");
                break;
         }

使用菜单中使用的任何标记的id代替li。

Instead of li, use id of whatever tag you use in menu.

这篇关于动态更改母版页中的菜单类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆