Click here to Skip to main content
15,885,900 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to set ForeColor of Text in Asp.Net.

I have a background color of #0066FF(Dark Blue) on this i have a text, I need Textcolor to be White(#FFFFFF)

This is my code

C#
strStudData = strStudData + string.Format("<img src='images/{0}.jpg' width='150' height='41' align='absmiddle' /> {1} {2} {3} <span class="style3" style="background-color:#0066FF"> {4} </span> ", readStud.Rows[i][4].ToString().Trim(), readStud.Rows[i][0].ToString(), readStud.Rows[i][1].ToString(), readStud.Rows[i][2].ToString(), readStud.Rows[i][3].ToString());


Please help.

Thanks
Posted
Updated 26-Feb-13 0:19am
v2

If you need to change text color of a textbox then you can use like..
C#
textbox1.ForeColor = Color.White;

or,in case a label..
C#
Label1.ForeColor = System.Drawing.Color.White;

A good example is..
http://asp-net-example.blogspot.com/2009/03/how-to-set-change-label-forecolor-font.html[^]
 
Share this answer
 
v2
Comments
HYD Webdeveloper 26-Feb-13 6:27am    
Please can anybody can do it in my above code.
ridoy 26-Feb-13 6:35am    
try with style="color:White" under that control tag in which you want to display your text.
HYD Webdeveloper 26-Feb-13 6:47am    
this is not working .... style="color:White"
ridoy 26-Feb-13 6:57am    
Ok,then see some relative approaches..
http://stackoverflow.com/questions/6404185/css-how-to-change-background-color-of-text
http://stackoverflow.com/questions/1178249/how-to-highlight-or-change-the-color-of-some-words-in-a-label-dynamically-at-run
Try:
HTML
<span class="style3" style="background-color:#0066FF;color:#FFFFFF;"> {4} </span>


If that doesn't work, then there's some other stylesheet value overriding your textbox color - which is very difficult to solve if we can't see your code.
 
Share this answer
 
v2
Try this this should work:

C#
trStudData = strStudData + string.Format("<img src='images/{0}.jpg' width='150' height='41' align='absmiddle' /> {1} {2} {3} <span class='style3' style='background-color:#0066FF;color:White;'> {4} </span> ", readStud.Rows[i][4].ToString().Trim(), readStud.Rows[i][0].ToString(), readStud.Rows[i][1].ToString(), readStud.Rows[i][2].ToString(), readStud.Rows[i][3].ToString());


Sreekanth
 
Share this answer
 
v3
hi dear,
try below

C#
strStudData = strStudData + string.Format("<img src="\'images/{0}.jpg\'" width="\'150\'" height="\'41\'" align="\'absmiddle\'" /> {1} {2} {3}  {4}  ", readStud.Rows[i][4].ToString().Trim(), readStud.Rows[i][0].ToString(), readStud.Rows[i][1].ToString(), readStud.Rows[i][2].ToString(), readStud.Rows[i][3].ToString());
 
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