I have a master page which has a DIV with asp:Hyperlink controls functioning as the menu for the site.
When I’m on a certain page if (document.title = ‘Certain Page’), I want javascript which will loop through all asp:hyperlink controls on the page and hide them (i.e. set to not visible). I know I could probably do this on the server side with less effort, but I’d rather do it via javascript.
You will need to decorate your
asp:Hyperlink‘s with aclassthat can be used to identify them on the client-side (you could also infer this from the control-id generation, but that would be more prone to errors, especially since ASP.NET 4.0 offers some alternatives).One these links have a common/consistent class then you would just need to have the Javascript select items with that class and hide them. Depending on your choice of client-side libraries (or lack thereof) this could be something like a simple line of jQuery (assuming your
asp:Hyperlinkshaveclass="aspLink"):$('.aspLink').hide();