[C#] Comment évaluer un double avec la fonction eval JavaScript ?
BOnjour à tous,
Je ne sais pas trop s'il faut poster sur le forum javascript ou celui-ci. J'ai choisi celui-là.
Mon problème, c'est l'évaluation d'un double par la fonction eval de javascript.
J'ai le code suivant: (en gras, là où ça coince !!)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
protected void View1_Load(object sender, EventArgs e)
{
double a = double.Parse(VIEW1_DETAILVIEW_NB_SITES_WHICH_FILLED.Rows[0].Cells[0].Text);
double b = double.Parse(VIEW1_DETAILVIEW_NB_SITES.Rows[0].Cells[0].Text);
double c = a / b;
double res = Math.Round(c, 2, MidpointRounding.ToEven);
VIEW1_DETAILVIEW_PERCENT_CSG_OK.Rows[0].Cells[0].Text = res.ToString() + " %";
VIEW1_DETAILVIEW_PERCENT_CSG_OK.FooterText="jhjh";
ClientScript.RegisterClientScriptBlock(typeof(string), "1", "<script language='javascript'>\n"+
"function helloWorld()\n{"+
"var a=eval(\"" + res + "\");alert(a);" + "var greenBorder = eval(\"121 * a\");\n" +
"alert(greenBorder);"+
"document.getElementById('VIEW1_DIV_PERCENT_CSG_OK').style.borderLeftWidth=greenBorder;\n" +
"document.getElementById('VIEW1_DIV_PERCENT_CSG_OK').innerHTML=greenBorder;}\n" +
"</script>\n");
} |
en fait, res vaut 0,02 mais la méthode eval de javascript me ressort 2
Je ne comprends pas pourquoi ???
Auriez vou une explication ? Une solution ??
Merci pour vos réponses !