母版页-突出显示未链接到菜单项的页面中的菜单项 [英] Master pages - highlighting menu items from pages not linked to the menuitem

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

问题描述


我是这个网站的新手,但是发现它对于查找信息非常有用.但是,我有一个问题,无法在任何地方找到解决方案.我有一个带有导航菜单的母版页.菜单项打开不同的页面,我可以使用"StaticSelectedStyle"属性和样式表突出显示所选的菜单项.

我现在遇到的问题是,我有第二个页面,不能直接从菜单中调用它,但是当该页面打开时,我希望突出显示某个菜单.

示例:

Page1由MenuItem1直接调用-显示Page1时,突出显示MenuItem1.

从Page1,我有一个调用Page2的按钮(此页面在任何菜单中均未调用).现在,MenuItem1不再突出显示,但我仍然希望它突出显示.

这有可能吗?

提前感谢!

Hi
I''m new to posting on this site, but have found it quite useful for finding information. I have a problem however, and am not able to find a solution anywhere. i have a masterpage with a navigation menu. The menu items open different pages, and i am able to highlight the selected menu item by using the "StaticSelectedStyle" property, and style sheet.

The problem i have now, is that I have a second page, which is not directly called from the menu, but when this page opens, I want a certain menu to be highlighted.

Example:

Page1 gets called directly by MenuItem1 - When Page1 displays, MenuItem1 is highlighted.

From Page1, I have a button that calls Page2 (this page is not called in any menu). Now, MenuItem1 is not highlighted anymore, but I still want it to be highlighted.

Is this possible at all?

Thanx in advance!

推荐答案

我认为我已经解决了自己的问题.没有会议和很多.最终很容易,但是感谢您的感谢.

在MasterPage Load中,循环浏览菜单项并进行一些检查.由于要加载的页面访问母版页,因此您只需要将特定菜单项的选定值设置为true.因此,即使我的项目"AAA"具有不同的URL链接,如果加载了其自己的页面以及加载了页面"BBB",该菜单项也会被突出显示.
在SiteMaster中Page_Load:
I think i solved my own problem. Without sessions and the lot. Was quite easy in the end, but thanx for your reply.

In MasterPage Load, loop through menu items and do some checks. Since the page being loaded accesses the masterpage, you just need to set the specific menuitems selected value to true. So, even though my item "AAA" has a different URL link, the menu item will be highlighted if it''s own page is loaded, as well as when page "BBB" is loaded.
In SiteMaster Page_Load:
foreach(MenuItem item in NavigationMenu.Items)
{
if (item.Value == "AAA" && Request.Path == "/BBB.aspx")
{item.Selected =true;}
else
{
item.Selected = Page.ResolveUrl(item.NavigateUrl).ToLowerInvariant() == Request.Path.ToLowerInvariant();
}


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

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