Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML
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 1-Aug-11 20:40pm
Edited 1-Aug-11 22:27pm
Dalek Dave432.9K
v2
Comments
Dalek Dave at 2-Aug-11 3:27am
   
Edited for Grammar and Readability.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try this
 

  <a href="#" id="someID" style="visibility: hidden">Check</a>
  Permalink  
v2
Comments
SAKryukov at 2-Aug-11 1:50am
   
Correct, a 5. It can be later modified in Javascript (otherwise why bothering?)
--SA
SAKryukov at 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 at 2-Aug-11 2:00am
   
Thanks SA
thatraja at 2-Aug-11 2:54am
   
5! I have posted an alternate
Dalek Dave at 2-Aug-11 3:27am
   
Good Answer.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

In addition to a correct solution by Mahendra:
 
In Javascript, this will hide it:
 
document.getElementByID(someID)style.visibility = 'hidden';
 
This will show it:
 
document.getElementByID(someID)style.visibility = 'visible';
—SA
  Permalink  
Comments
thatraja at 2-Aug-11 2:54am
   
5! I have posted an alternate
SAKryukov at 2-Aug-11 3:04am
   
Thank you, Raja.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Here another way
<a href="#" id="someID" style="display: none">Check</a>
Using Javascript
document.getElementByID('someID')style.display = 'none';
  Permalink  
Comments
SAKryukov at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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
 
runat="server"
 
and then access it directly at code behind to show or hide.
 
What say?
 

Anurag
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,142
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 2 Aug 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100