在masterpage的.cs文件中控制实现对ul子菜单的收缩,怎么样通过js控制页面刷新后菜单还是展开来的
页面:leftMenu.aspx
1 privatestring _dir =string.Empty;
2 publicstring Dir
3 {
4 get
5 {
6 return _dir;
7 }
8 set
9 {
10 _dir = value;
11 }
12 }
13
14 protectedvoid Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
15 {
16 DataRowView dr = e.Item.DataItem as DataRowView;
17 string item_id = dr["ItemFamilyID"].ToString();//companyid ='TEXFACTOR' and
18 string sql ="select * from Tab where companyid ='aa' and ItemFamilyID='"+ item_id +"'";
19 DataSet dsid = child.Query(sql);
20 (e.Item.FindControl("Repeater2") as Repeater).DataSource = dsid;
21 (e.Item.FindControl("Repeater2") as Repeater).DataBind();
22 }
View Code
<script language="javascript">
function fun(id) {
var a = document.getElementById(id);
if (a.style.display =="none") { //我该怎么动态获取子菜单的id,让母版页刷新后,子菜单依然保持展开状态。
a.style.display ="block";
}
else {
a.style.display ="none";
}
}
</script>
<table border='0' width='100%' cellspacing='0' cellpadding='0' class='infoBox_table' style="display:block">
<tbody>
<tr>
<td class='infoBox_td'>
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<table border='0' width='100%' cellspacing='0' cellpadding='0' onclick="fun('t<%#Eval("ItemFamilyID") %>')"
class='infoBoxContents2_table'>
<tbody>
<tr>
<td class="boxText" style="height: 6px;">
<ul class='categories'>
<li class='bg_list' id="l1"><a href='#'>
<%#Eval("ItemFamilyID")%>
</a></li>
</ul>
</td>
</tr>
</tbody>
</table>
<table border='0' width='100%' cellspacing='0' cellpadding='0' class='infoBox_table' style="display:none"
id="t<%#Eval("ItemFamilyID") %>" style="display: none;">
<asp:Repeater ID="Repeater2" runat="server">
<ItemTemplate>
<tr>
<td class="boxText" style="height: 6px;">
<ul class='categories'>
<li class='bg_list' id="l1" style="padding-left: 30px; width: 213px;"><%--onclick="Chuan();"--%>
<a style="text-decoration: none;" target="_parent" href="<%=Dir %>default.aspx?id=<%#Eval("ItemCategoryID") %>">
<%#Eval("ItemCategoryID")%>
</a></li>
</ul>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</tbody>
</table>
href="<%=Dir %>default.aspx?id=<%#Eval("ItemCategoryID") %>"
左边的这个菜单是在母版页里面
当点击子节点,显示相关数据在右边,同时页面会刷新
刷新后,子菜单收起来了,我需要它还是展开的