Question

My master page has anchor tag,which i want to disable on other page.But the disable property of anchor tag does not work.

Below is the code i have used.

Dim LinkLogout As HtmlAnchor
LinkLogout = CType(Master.FindControl("LogOutLi"), HtmlAnchor)          
LinkLogout.Disabled = True
Était-ce utile?

La solution 2

I got the way to disable completely an anchor tag:

Dim LinkLogout As HtmlAnchor
LinkLogout = CType(Master.FindControl("LogOutLi"), HtmlAnchor)
LinkLogout .HRef = "javascript:void(0)"

Autres conseils

Setting the Disabled property will put a disabled attribute on the anchor tag. However, disabled is not a valid attribute for an anchor tag so for browsers like Firefox, it will not work. Funny enough, I tried it in IE and it works.

I don't know the full extent of what you're doing and I believe there would be a better way of doing what you need but for the purpose of solving your issue, you can set add an onclick event to return false and the anchor should act as if it was disabled.

Dim LinkLogout As HtmlAnchor
LinkLogout = CType(Master.FindControl("LogOutLi"), HtmlAnchor)
LinkLogout.Attributes.Add("onclick", "return false;")
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top