我使用计时器将更改面板中的导航代码放入,但一分钟后,活动菜单消失,页面上没有显示活动菜单,但所选页面仍然存在....
让我分享我的代码..
更新面板计数器的代码 Aspx代码:
<asp:UpdatePanel runat="server" id="UpdatePanel1">
<ContentTemplate>
<asp:Timer runat="server" id="Timer1" Interval="10000" OnTick="Timer1_Tick"></asp:Timer>
<nav class="navbar-default navbar-side" role="navigation" style="background-color: #333333; height:100%;">
<div class="sidebar-collapse" style="background-color: #333333; height:100%;">
<ul class="nav" id="main-menu">
<li class="text-center">
<img src="../assets/img/Logo.jpg" class="user-image img-responsive"/> </li>
<li>
<a class="active-menu" id="MDB" href="ManagerDashBoard.aspx"><i class="fa fa-dashboard fa-3x"></i>Manager DashBoard </a>
</li>
<li>
<a href="#"><i class="fa fa-sitemap fa-3x"></i>Messages<span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li>
<a id="MNMF" href="ManagerNewMessageForm.aspx">Create New Message</a>
</li>
<li>
<a id="MI" href="ManagerInbox.aspx?Status=11">Inbox<span class="in-badge"><asp:Label ID="mgInLabel1" runat="server" Text=""></asp:Label></span> </a>
</li>
<li>
<a id="MS" href="ManagerInbox.aspx?Status=22">Send<span ></span> </a>
</li>
</ul>
</li>
<li>
<a href="#"><i class="fa fa-sitemap fa-3x"></i>Suggestion Follow Up<span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li>
<a id="MP" href="ManagerNewSuggestion.aspx?Status=7">Pending <span class="mr-badge"><asp:Label ID="SMRPLabel1" runat="server" Text=""></asp:Label></span> </a>
</li>
<li>
<a id="MPP" href="ManagerNewSuggestion.aspx?Status=3">Postpone<span class="pp-badge"><asp:Label ID="PPLabel1" runat="server" Text=""></asp:Label></span> </a>
</li>
<li>
<a id="MAR" href="ManagerNewSuggestion.aspx?Status=6">Archived<span class="ar-badge"><asp:Label ID="SARLabel4" runat="server" Text=""></asp:Label></span></a>
</li>
</ul>
</li>
<li>
<a href="#"><i class="fa fa-sitemap fa-3x"></i>Account Setting<span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li>
<a id="MAC" href="ManagerAccount.aspx">Account Control</a>
</li>
<li>
<a id="MUP" href="ManagerPassword.aspx">Update Password</a>
</li>
</ul>
</li>
</ul>
</div>
<div style="background-color: #333333; height: 400px;">
</div>
</nav>
</ContentTemplate>
C#代码:
public void msgcounter()
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["FBMNGTConnectionString"].ConnectionString);
con.Open();
int msgstatusid = 0;
while (msgstatusid < 22)
{
string strquery2 = string.Empty;
strquery2 = "select count(Status) as msgcntstatus from MessageApprovalTable where Status = " + msgstatusid + " and ToEmployee_ID =" + Session["Employee_Id"];
SqlCommand cmd2 = new SqlCommand(strquery2, con);
SqlDataAdapter sda = new SqlDataAdapter(cmd2);
DataSet ds = new DataSet();
sda.Fill(ds);
string mgcount = Convert.ToString(ds.Tables[0].Rows[0]["msgcntstatus"]);
switch (msgstatusid)
{
case 11:
mgInLabel1.Text = Convert.ToString(mgcount);
break;
//case 22:
// mngsndLabel1.Text = Convert.ToString(mgcount);
// break;
//case "2":
// strquery += " where Suggestion_Status = 2";
// break;
default:
break;
}
msgstatusid++;
}
}
protected void Timer1_Tick(object sender, EventArgs e)
{
counter();
msgcounter();
}
答案 0 :(得分:0)
请将以下行添加到Timer_Tick, Put,菜单ID:MDB; RUNAT =&#34;服务器&#34;
<强> MDB.attributes.add(&#34;类&#34;&#34;有源菜单&#34); 强>
对于所有页面您可以在菜单项
上获取href值或Page Name For Applied Active类