【发布时间】:2016-05-19 08:57:53
【问题描述】:
我是 Asp.Net 的新手。在我的应用程序中,当单击用户名显示子菜单并退出时,我需要在菜单中显示用户名。所以我就这样尝试了
<div id="DivRight">
<ul> <li><asp:LinkButton ID="lblusername" CssClass="imjusttext"
ForeColor="#1570a6" Font-Underline="false" Text="Admin" OnClientClick="return false"
runat="server"/></li></ul>
</div>
<div id="DivSubMenuRight" style="display:none" runat="server">
<ul> <li><asp:LinkButton ID="lblSignout" CssClass="imjusttext" ForeColor="#1570a6"
Font-Underline="false" Text="Sign Out" OnClientClick="return false" runat="server"/>
</li></ul>
</div>
我需要服务器代码中的点击事件,所以我使用linkbutton。
ASP.NET
Protected Sub lblusername_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles lblusername.Click
DivSubMenuRight.Visible = True
End Sub
Protected Sub lblSignout_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles lblSignout.Click
FormsAuthentication.SignOut();
End Sub
CSS
.imjusttext{ color: #1570a6; text-decoration: none; }
.imjusttext:visited { color: #1570a6; text-decoration: none; }
编辑
当我点击用户名然后显示 div 就像我们在这里悬停一些标签名称时,它以黑色显示矩形框。像那样。怎么做 ?而且我需要在服务器端编码中正确注销单击事件以进行用户身份验证,以便编写它。因为它是一个链接按钮?
我正在使用 ASP.NET 2008
【问题讨论】:
-
为什么你没有使用正确的菜单控制,添加用户名作为顶部和注销作为子/子菜单。 msdn.microsoft.com/en-us/library/ecs0x9w5.aspx
标签: javascript html css asp.net