I defined a Viewbag in .cshtml file as
ViewBag.version = "2.0";
but when I get the value:
alert(@ViewBag.version.ToString());
It shows as 2, it takes out .0 after
CodePudding user response:
As General Grievance
said,@ViewBag.version.ToString()
will be Number
,so you can use ''
.
alert('@ViewBag.version.ToString()');
Also you can try to convert it to float and formats the number using fixed-point notation.
alert(parseFloat(@ViewBag.version.ToString()).toFixed(1));