【发布时间】:2014-08-12 17:37:53
【问题描述】:
我正在尝试使用 aspx 网络表单中的 j 查询来显示当前处于活动状态的链接。
首先,我通过这个函数从后面的代码生成了从我的数据库到 gallery.aspx 的所有超链接:
public string build_Gallery_Category()
{
string post = "";
DataTable dt = new DataTable();
clsBusiness cls = new clsBusiness();
dt = cls.Fill_In_DataTable("GalleryGroup");
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
post += "<li><a href='gallery.aspx?gid=" + dt.Rows[i]["GalleryId"].ToString() + "'><strong>" + dt.Rows[i]["GalleryName"] + "</strong></a></li>";
}
}
return post;
}
所以,在我调用该方法后,所有超链接都会出现在 gallery.aspx 上,如下所示:
<div id="menu">
<ul>
<%=viewCategory %>
</ul>
</div>
之后,将此样式添加到 gallery.aspx:
<style>
.active { background: #f00; }
</style>
毕竟,我在 from 的末尾添加了 jquery 代码:
<script>
$("menu li").click(function (e) {
e.preventDefault();
$("menu li a.active").removeClass("active"); //Remove any "active" class
$("a", this).addClass("active"); //Add "active" class to selected tab
});
</script>
但我的代码不起作用......所以请帮助我。非常感谢...
【问题讨论】:
-
build_Gallery_Category在gallery.aspx? -
不,它在单独的类中并从 gallery.aspx.cs 调用它