问题
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