Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have this method in javascript

C#
var ModifiedNumericValueWithDecimal = function (value, metadata, record) {
          if (value == null || value == 'undefined') return '';
          if (isNaN(value)) return value;
          if (value < 0) {
              return "(" + Math.abs(value) + ")";
          }
          if (parseFloat(value) > parseFloat(0.0)) {
              return Ext.util.Format.number(value, '0,000,000');
          }
          else return value;
      };




i want that when it return
return "(" + Math.abs(value) + ")";
thn value shoule be in red color
Posted
Comments
Samatha Reddy G 9-Oct-14 6:29am    
Where you are displaying that value? are you bind it to any label or span or div
sanjaysgh 9-Oct-14 6:30am    
it is inside grid
Samatha Reddy G 9-Oct-14 6:37am    
try like this on rowdatabound

if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lbl=(Label)e.Row.FindControl("lblStatus");
if (lbl.Text == "1")
{
lbl.Text = "IN";
e.Row.Cells[2].BackColor = Color.Blue;
e.Row.Cells[2].ForeColor = Color.White;
}
}
[no name] 9-Oct-14 6:33am    
can you please explain ur problem in detail ?
sanjaysgh 9-Oct-14 6:36am    
provide any solution

this might help you

JavaScript
<p style="color : #f00;">
<%=ModifiedNumericValueWithDecimal>
</p>
 
Share this answer
 
v2
At least couple of ways :)

First:
1. create CSS class with color: red
CSS
.red-text { color: red;}

2. add it to your element when needed
JavaScript
$("#your-element").addClass("red-text");

similarly call
JavaScript
$("#your-element").removeClass("red-text");

when it should look normal

Second: add the css property directly (again when needed)
JavaScript
$("#your-element-id").css("color", "red");

and to reset it
JavaScript
$("#your-element-id").css("color", "");


First solution is better because a) it can be re-used whenever you need red text and b) you can change the color in your CSS without hunting for the places where you use the function...
 
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