Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HI,

How to change the text and forecolor of a asp label using javascript.



Thanks

Dileep
Posted
Comments
AmitGajjar 17-Aug-12 4:58am    
Please check my updated solution.

Here is some similar discussions. Follow the links:
http://www.webdeveloper.com/forum/showthread.php?t=192329[^]
http://www.codingforums.com/archive/index.php/t-48381.html[^]

You can try javascript fontcolor()[^] method also to change the forcolor.




--Amit
 
Share this answer
 
JavaScript
// Change text
 document.getElementById("<%=asplabelid.ClientID %>").value = "TEXT";
//Change Color
document.getElementById("<%=asplabelid.ClientID %>").style.color= "Red";
 
Share this answer
 
v2
Comments
Ganesh Nikam 17-Aug-12 3:05am    
not asplablename its asplabelid then it will work otherwise not work
You can use like this:

document.getElementById("My_ID").innerHTML="<font color=#FF0000>Place Your Test</font>"

My_Id will be your Lable ID or Td ID or div id what so ever...
 
Share this answer
 
Hi,

Below both the discussion will work with jQuery(Javascript API). and hope it will resolve your issue.

Hint for changing Font color of any element by changing css class associated with that[^] (this is not exact code. you need to think to resolve your issue)

Change text of label using jQuery[^]

Thanks
-Amit Gajjar
 
Share this answer
 
v2

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