All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
简单自定义实现jQuery验证_[AJAX教程]
深入Atlas系列之服务器端支持(上)_.net资料_编程技术
PHP脚本的8个技巧(8)PHP和XML_[PHP教程]
基于PHP和AJAX创建RSS聚合器_[PHP教程]
一些关于SQL2005+ASP.NET2.0的问题_[Asp.Net教程]
PHP脚本的8个技巧
十分钟学会 xajax_[AJAX教程]
模板用xml的思路_[PHP教程]
如何在十天内学会php之第一天_[PHP教程]
GMap谷歌地图实现代码_[Asp.Net教程]
Reading number is top 10 pictures
A man's favorite things11
Look for from human art net, is good--3
China railway shunting skills competition
关于海盗的研究2
美女挤公交
西游日记4
非笑不可:最强爆笑图片精选
The other a successor of sora aoi
The money of more than 100 countries and regions11
Beautiful vacuum girl1
Download software ranking
Tram sex maniac 2 (H) rar bag15
少妇苏霞全本
Photoshop 8.0图象编辑软件
WebService在.NET中的实战应用教学视频 → 第3集
Take off clothes to survival
Call Of Duty2
Boxer's Top ten classic battle10
美女游泳记
Unix video tutorial2
jBuilder2006
delv published in(发表于) 2014/1/24 9:02:31 Edit(编辑)
ASP.NET,+,CSS实现动态菜单突出显示当前页面_[Asp.Net教程]

ASP.NET,+,CSS实现动态菜单突出显示当前页面_[Asp.Net教程]

ASP.NET + CSS实现动态菜单突出显示当前页面_[Asp.Net教程]

搞了两天的问题终于解决了,网上关于突出显示当前页面的文章有不少,但是基本都是关于实现静态菜单的高亮,讲到动态生成菜单高亮的文章至少我没有找到,在csdn上问了两天都没有答案,最后在一位朋友的回答中找到思路,先利用一个函数判断菜单是否是正在浏览的当前页,然后付给li一个id,利用css层叠id大于class的关系,把这个id定义成高亮样式。

aspx文件代码

引用内容









后台代码:vb版本
引用内容

Public Function getCss(ByVal Url As Object) As String
Dim curPageName As String = HttpContext.Current.Request.Url.Segments(HttpContext.Current.Request.Url.Segments.Length - 1)
If Url.ToString.ToLower = curPageName.ToLower Then
Return "id='activer'"
Else
Return Nothing
End If
End Function


C#版本
引用内容

public string getCss(object Url)
{
string curPageName = HttpContext.Current.Request.Url.Segments(HttpContext.Current.Request.Url.Segments.Length - 1);
if (Url.ToString.ToLower == curPageName.ToLower) {
return "id='activer'";
} else {
return null;
}
}


CSS样式
引用内容 引用内容

.navigation {
background: url(../images/navigation-bg.png);
height: 38px;
width :1003px;
overflow: hidden;
line-height: 2em;
}

.navigation ul {
list-style: none;
margin: 0 auto;
padding: 0;
text-align: left;
width: 970px;
}

.navigation ul li {
background: none;
display: inline;
float: left;
list-style-type: none;
padding: 0;
}

.navigation ul li a {
color: #666;
display: block;
height: 25px;
overflow: hidden;
padding: 5px 15px 0 15px;
text-decoration: none !important;
}

.navigation ul li a:hover {
color: #fff !important;
}
#activer a{ '这个就是高亮菜单的样式,这里我用了背景图片
background: url(../images/navigation-active.gif);
color: #a21 !important;
font-weight: bold;
cursor:default; '把鼠标样式改为默认的箭头,即不会诱使用户点击连接
}



最后效果图


来源:http://www.morock.net/blog/article.asp?id=78






添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.