Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
How can I hide an anchor tag in html?

Before the user Login, I don't want to display the search option.

After login, I want to display the search option.
Posted
Updated 7-Nov-17 14:10pm
v2
Comments
Dalek Dave 2-Aug-11 3:27am    
Edited for Grammar and Readability.

try this


<a href="#" id="someID" style="visibility: hidden">Check</a>
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 2-Aug-11 1:50am    
Correct, a 5. It can be later modified in Javascript (otherwise why bothering?)
--SA
Sergey Alexandrovich Kryukov 2-Aug-11 1:57am    
I added id to your tag for the purpose of using it in my solution which should complement yours (I hope you don't mind). In my solution, I used it to show how to show/hide the element dynamically using Javascript, please see.
--SA
Mahendra.p25 2-Aug-11 2:00am    
Thanks SA
thatraja 2-Aug-11 2:54am    
5! I have posted an alternate
Dalek Dave 2-Aug-11 3:27am    
Good Answer.
Here another way
HTML
<a href="#" id="someID" style="display: none">Check</a>

Using Javascript
JavaScript
document.getElementByID('someID')style.display = 'none';
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 2-Aug-11 3:05am    
Oh yes, I almost forgot this one. My 5, but you better explain how to show it dynamically as well (OP needs to show dynamically, not to hide).
--SA
In addition to a correct solution by Mahendra:

In Javascript, this will hide it:

JavaScript
document.getElementByID(someID)style.visibility = 'hidden';


This will show it:

JAS
document.getElementByID(someID)style.visibility = 'visible';

—SA
 
Share this answer
 
Comments
thatraja 2-Aug-11 2:54am    
5! I have posted an alternate
Sergey Alexandrovich Kryukov 2-Aug-11 3:04am    
Thank you, Raja.
--SA
To be more precise to all above given solutions, you would need to check that whether user is logged in before making the link visible. That means, from code behind you would require run a javascript to make the link visible. This can be done using Page.ResigerClientScript block (google can tell you a lot about this). Also, since you are checking the session variable at code behind, then why not to make the anchor tag

C#
runat="server"


and then access it directly at code behind to show or hide.

What say?


Anurag
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900