突出显示所选的母版页菜单项 [英] Highlight selected Masterpage Menu item

查看:130
本文介绍了突出显示所选的母版页菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友:
我在c#asp.net项目中使用母版页.我必须突出显示母版页中的选定菜单项,因为我尝试了从子页面都无法使用的静态菜单选定样式和动态选定菜单样式,该怎么做,请帮帮我....

Hello Friends:
I am using master-page in my c# asp.net Project. I have to highlight Selected menu item in master page in that i tried Static menu selected style and Dynamic Selected Menu style that are all not working from child pages how to do that please help me....

推荐答案

假设您要的是"webforms"解决方案,下面给出的是实现此目的的一种方法:

1.在母版页中有一种方法,内容页可以调用

Assuming you are asking for a "webforms" solution, given below is one way of how you could achieve this:

1. Have a method in your master page that the content pages can call

public partial class MyMaster : ....
{
     public void SelectIcon(string someParameter)
     {
            // add the class to the icon / link text to make it selected
     }
}



2.在内容页面中添加MasterType标头(参考- http://msdn.microsoft.com/zh-cn/library/xxwa0ff0.aspx [ ^ ])

3.在内容页面的代码中调用该方法,如Master.SelectIcon

希望这可以帮助!如果有任何问题需要发表评论!



2. Add MasterType header in your content pages (reference - http://msdn.microsoft.com/en-us/library/xxwa0ff0.aspx[^])

3. Call the method in content page''s code-behind like Master.SelectIcon

Hope this helps! If any questions drop in a comment!


我认为您尚未设置静态和动态MenuItems的SelectedStyle 属性

这样吧..
I think you haven''t set the SelectedStyle property of static and dynamic MenuItems

Do it like this..
<asp:menu id="menuBar" runat="server" orientation="Horizontal" width="100%" xmlns:asp="#unknown">
      <dynamichoverstyle cssclass="DynamicHover" />
      <dynamicmenuitemstyle cssclass="DynamicMenuItem" />
      <dynamicselectedstyle cssclass="DynamicSelected" />
                   
      <statichoverstyle cssclass="staticHover" />
      <staticmenuitemstyle cssclass="StaticMenuItem" itemspacing="1px" />
      <staticselectedstyle cssclass="StaticSelected" />
</asp:menu>



在这里,在CSS文件中定义DynamicSelected和StaticSelected类,并设置希望菜单在选择时具有的样式..



Here define DynamicSelected and StaticSelected classes in your css file and set the style you want the menu to have when selected..


这篇关于突出显示所选的母版页菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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