For certain condition I want to disable my tag and I have tried following so far
//codebehind
if(condition)
{
aTag.Disabled.Equals(true);
}
//.aspx page
<a id="aTag" runat="server"></a>
it's not working, I don't know whats the matter, If anybody know please give me the better solution, thanks.
You can use javascript:void(0);
to kill the link.
<a id="aTag" runat="server">You cannot click me!</a>
if(condition)
{
aTag.HRef = "javascript:void(0);";
}
You could try using the disabled html attribute .. not sure it works for links though.
aTag.Attributes.Add("disabled","disabled");
Update: disabled doesn't work for links
Maybe what you need is to remove the value in the href.
aTag.Attributes["href"]= "#";
Or remove it.
aTag.Attributes.Remove("href");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With