Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
string link = "<a href= \"https://www.google.se\">https://www.google.se</a>";


how could i style this string= i want to use color on it?
Posted
Comments
jaket-cp 20-Jan-15 11:42am    
What do you mean colour the string?
If you mean style the generated html on the web browser, I may get what you mean.
Kurac1 20-Jan-15 11:43am    
yes to style it
Sergey Alexandrovich Kryukov 20-Jan-15 11:47am    
And what prevents you?
—SA
Kurac1 20-Jan-15 11:50am    
why does not this work? var lbl = new Label();
lbl.Text = link;
lbl.ForeColor = Color.Blue;

The browser should automatically style the link for you.
For the basics on CSS styles for anchors, try http://www.w3schools.com/css/css_link.asp[^].
 
Share this answer
 
v2
Comments
Kurac1 20-Jan-15 14:11pm    
Yes but this will style all my ahref links
Abhinav S 20-Jan-15 16:10pm    
Then create a css cxlass and apply it only to this link. That will solve your problem.
If this is real anchor, you just use CSS for anchor pseudo-classes, a:link, a:visited, and so on: http://www.w3schools.com/css/css_pseudo_classes.asp[^].

Try not to deviate from commonly accepted styles too far: the users should easily recognize links.
CSS color properties are color and background-color.

If you mean that you want to put not a real anchor, but render the strings showing the anchor syntax, first escape HTML using HTML character entities: http://www.w3schools.com/htmL/html_entities.asp[^].

And then, style it the way you like. If you have even the basic idea how CSS works (it is mentioned in your question tags), you know how to do it. If not, see this and find documentation by links on this page:
http://en.wikipedia.org/wiki/Cascading_Style_Sheets[^].

—SA
 
Share this answer
 

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