Click here to Skip to main content
15,907,183 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello to all!


i am not able to underline the anchor tag but href working fine here is my code:



<a  class="anchortext-decoration" id="ancbusinessurl"   runat="server" style="font-style: normal"></a>

ancbusinessurl.HRef =  dt.Rows[0]["BusinessUrl"].ToString();

ancbusinessurl.InnerText =("<u>" + dt.Rows[0]["BusinessUrl"].ToString()+"</u>");


thanx in advance
Posted
Updated 27-Feb-11 19:34pm
v2

What is ancbusinessurl?

Use CSS, such as

a
{
  text-decoration: underline;
}


Don't use
 
Share this answer
 
Comments
balongi 28-Feb-11 1:28am    
ancbusinessurl is anchor tag id. when i run my code it display hello i want hello come in underline
you can also try this :
ancbusinessurl.style.Add("text-decoration","underline");
 
Share this answer
 
v2
Comments
[no name] 28-Feb-11 1:44am    
Inline styles are poor design that does not allow for flexibility in future requirements. What happens when users what the link underlined only when hovering?
Monjurul Habib 28-Feb-11 2:04am    
ok , then you can easily define a css class for anchor. what is the problem with that ??
[no name] 28-Feb-11 7:35am    
ANd the inline style will always take precedence of the the CSS style sheet. Do you understand how CSS works?
Monjurul Habib 28-Feb-11 7:40am    
yes i do.so far i know if you write the css it will work for the whole project.but if you need a particular anchor should show underline?? what we need to do then, write another class??
[no name] 1-Mar-11 18:41pm    
You are getting into the ridiculous now just to try proving you point.
Ever heard of CSS grouping and nesting.
If you want to set in codebehind
C#
ancbusinessurl.Style.Value="text-decoration:underline;";

in html
<a id="aid" runat="server" style="text-decoration:underline;">test</a>
 
Share this answer
 
Comments
[no name] 28-Feb-11 1:43am    
Inline styles are poor design that does not allow for flexibility in future requirements. What happens when users what the link underlined only when hovering?
Monjurul Habib 28-Feb-11 1:57am    
ok , then you can easily define a css class for anchor. what is the problem with that ??
m@dhu 28-Feb-11 2:05am    
Yes true. But from op question he did try using the style from code behind I just modified what he was trying to get correct.But still my answer don't deserve a -16.
[no name] 28-Feb-11 7:34am    
It is a poor design, regardless of whether the OP used it forst or not. What happens when someone does create a CSS style for the anchor tags? It will have no effect because the inline style will always override. Your idea solves a problem but doesn't offer a solution. Poor designs deserve to be voted accordingly.
Hi,
If ancbusinessurl is asp.HyperLink then try this

ancbusinessurl.NavigateUrl=  dt.Rows[0]["BusinessUrl"].ToString();

Thanks
 
Share this answer
 
Comments
balongi 28-Feb-11 1:33am    
ancbusinessurl is anchor tag id
[no name] 28-Feb-11 1:44am    
This does nothing to apply any style such as underlining

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