Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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
 
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 26-Feb-13 0:15am
Edited 26-Feb-13 0:19am
ridoy51.9K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If you need to change text color of a textbox then you can use like..
textbox1.ForeColor = Color.White;
or,in case a label..
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[^]
  Permalink  
v2
Comments
HYD Webdeveloper at 26-Feb-13 6:27am
   
Please can anybody can do it in my above code.
ridoy at 26-Feb-13 6:35am
   
try with style="color:White" under that control tag in which you want to display your text.
HYD Webdeveloper at 26-Feb-13 6:47am
   
this is not working .... style="color:White"
ridoy at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Try:
     <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.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Try this this should work:
 
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
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

hi dear,
try below
 
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());
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.141022.2 | Last Updated 26 Feb 2013
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