本文介绍了Reg;:代码behing中的锚标签可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 Aspx页面中的我的Anchor标签: < a id = angerBonusPoints href = ../ MyHome / UserBonusPoints.aspx rel = external data-role = 按钮 样式 = visibility:hidden data-icon = gear data-theme = a class = bonus runat = server > 奖励积分 i已给出 visibility = hidden 所以它的工作正常标签按钮不会在所有页面中显示 但是我希望这个锚点按钮可见一个特定的页面如何做到这一点。 我的Code behiind页面休闲: if (Request.FilePath.ToString()。ToLower()。Contains( / myhome / home)) { angerBonusPoints.Visible = true ; angerBonusPoints.Attributes.Add( href, 〜/ MyHome / UserBonusPoints.aspx); } i希望该锚点按钮只显示一页,但不起作用。 请完成需要 问候, Madhu 解决方案 从标签的HTML中删除 style =visibility:hidden然后使用 Visible = false ; 您想隐藏它的位置和 Visible = 真; 您想要在哪里显示它。 在 runat =server属性到锚标记。设置属性后,您将能够通过代码访问锚标记。在那里你可以设置锚标记的可见属性为 true 或 false 。 试试这个: < a id = angerBonusPoints runat = server href = ../ MyHome / UserBonusPoints.aspx rel = external data-role = 按钮 visible = false data-icon = gear data-theme = a 类 = 奖金>奖励积分 < / a > C#: angerBonusPoints.Visible = true ; // 使锚点可见 angerBonusPoints.Visible = 假; // 隐藏锚 My Anchor tag in Aspx page: <a id="angerBonusPoints" href="../MyHome/UserBonusPoints.aspx" rel="external" data-role="button" style="visibility: hidden" data-icon="gear" data-theme="a" class="bonus" runat="server">Bonus Points i have given visibility= hidden so its working fine tag button is not visibiling in all pages but i want this anchor button to be visible for one specific page how to do this. my Code behiind page fallows: if (Request.FilePath.ToString().ToLower().Contains("/myhome/home")){ angerBonusPoints.Visible = true;angerBonusPoints.Attributes.Add("href", "~/MyHome/UserBonusPoints.aspx");} i want that anchor button to be visible for the only one page but its not working.pls do the need full Regards,Madhu 解决方案 Remove style="visibility: hidden" from the HTML of your tag and then use Visible = false; wherever you want to hide it and Visible = true; wherever you want to show it.At runat="server" property to the anchor tag. After setting the property you'll able to access anchor tag through code. There you can set Visible property of anchor tag to true or false.Try this:<a id="angerBonusPoints" runat="server" href="../MyHome/UserBonusPoints.aspx" rel="external" data-role="button" visible="false" data-icon="gear" data-theme="a" class="bonus">Bonus Points</a>C#:angerBonusPoints.Visible = true; //For making anchor visibleangerBonusPoints.Visible = false; //For hiding anchor 这篇关于Reg;:代码behing中的锚标签可见性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-30 19:30