Disable a HyperLink from code behind
In my project I need to disable a hyperlink based on some condition开发者_运维百科. So how can I do this from code behind using C#?
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;
in your aspx, add runat="server" and id attribute to the tag:
in Page_load method: if(condition) ep_sms.HRef = "#";
myHyperLink.Enabled = false;
does not work with <a>
links
Instead use aria-disabled="true"
In your method add this:
myHyperLink.Attributes.Add("aria-disabled", "true");
links:
https://a11y-guidelines.orange.com/en/articles/disable-elements/#:~:text=It%20is%20still%20possible%20to,is%20indicated%20as%20being%20disabled
How to add custom attributes to ASP.NET controls
精彩评论