Disable a HyperLink from code behind

◇◆丶佛笑我妖孽 提交于 2019-12-23 11:59:31

问题


In my project I need to disable a hyperlink based on some condition. So how can I do this from code behind using C#?


回答1:


in your aspx, add runat="server" attribute to the tag:

<a id="myHyperLink" runat="server">...</a>

in Page_load method:

if( condition )
    myHyperLink.Enabled = false;



回答2:


in your aspx, add runat="server" and id attribute to the tag:

in Page_load method: if(condition) ep_sms.HRef = "#";



来源:https://stackoverflow.com/questions/3413754/disable-a-hyperlink-from-code-behind

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!