与asp超链接控件的可见性有关的问题 [英] Problem Related to asp Hyperlink Control's Visibility
问题描述
<!-- Home -->
<li class="current"><a href="Home.aspx">Home</a>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="userwelcome.aspx">My Page</asp:HyperLink></li>
</li>
我想在session ["username"] == null时隐藏此超链接,
而且我的想法很好,但是当session为null时就会出现问题,因为它与
i want to hide this hyperlink when the session["username"]==null,
and my this idea working fine but there is a problem when session is null then because it is with in
<li>hyperlink</li>
因此它在超链接"中隐藏了我的页面"文本,但显示了空白方形"框.(因为当可见性为false时,超链接的文本不存在)
我想隐藏这个空白的方形框.
有任何想法吗?
so it hides the My Page text from the Hyperlink but showing Blank Square box.(because hyperlink''s text is not there when visibility is false)
i want to hide this blank Square box.
Any Idea?
推荐答案
我不确定我是否很好地解决了您的问题...
要隐藏超链接,您只需键入:
I am not sure I get your problem well...
To hide the hyperlink you can just type:
HyperLink1.Visible = !(session["username"]==null);
如果出现渲染问题,则可能是probalby,因为您只有2个闭合"li"用于一个开口.
If you have rendering issue it is probalby because you have 2 closing "li" for only one opening.
您好
您可以在li内使用runat ="server"属性,并在隐藏链接按钮时也将其隐藏.希望对您有所帮助.
Hi
You can use a runat="server" attribute inside li and hide that also when you hide the link button. Hope that helps you.
<ul runat="server" id="hide">
<li> <asp:hyperlink id="HyperLink1" runat="server" navigateurl="userwelcome.aspx" xmlns:asp="#unknown">My Page</asp:hyperlink></li></ul>
然后在代码后面我写了
and in codebehind i wrote
if (Session["email"] == null)
{
HyperLink1.Visible = false;
hide.Visible = false;
}
else if (Session["email"] != null)
{
HyperLink1.Visible = true;
hide.Visible = true;
}
我添加了
I Added
Runat="Server"
和
id="hide"
到
<ul>
标签,然后在会话为null时将可见性设置为false,否则设置为true:)
tag then set the visibility false when session is null else true :)
这篇关于与asp超链接控件的可见性有关的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!