Tag: 货币格式

Knockout / JQuery货币格式

我有下面的页面工作得很好(我已经删除了一些其他字段和样式,以保持我在这里发布的样本很小)。 我希望表中的Premium行(第17行)格式化为货币(USD)。 这样做的最佳方法是什么? Location Name Location Total $(document).ready(function () { var appViewModel // AppViewModel function AppViewModel() { this.Locations = ko.observable([]); } var appViewModel = new AppViewModel(); ko.applyBindings(appViewModel); $.getJSON(“http://waltweb01:85/LTCEPLWS/LTCJSON.svc/getLTCWithIDs/4”, function (data) { incomingData = data; appViewModel.Locations(data.getLTCWithIDsResult.Locations); }); });

如何为MVC EditorFor设置货币格式?

我必须使用货币格式显示项目金额的页面。 第一个是输入货币的地方,第二个是货币显示的地方。 我希望EditorFor显示一个R表示Rands然后我希望该值为十进制。 这是我的EditorFor: @Html.EditorFor(model => model.TransactionModel.Price) 我尝试了很多不同的方法,无法工作。 通过下面的这个例子,它不知道第二行中的’CurrencyPrice’是什么。 var CurrencyPrice = ‘@Model.TransactionModel.Price’; document.getElementById(‘TransactionModel.Price’).value = ‘@string.Format(“{0:C}”, CurrencyPrice)’; 我也在我的transactionModel中尝试了这些: //[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = “{0:c}”)] //[UIHint(“Currency”)] //[DisplayFormat(DataFormatString = “{0:F2}”, ApplyFormatInEditMode = true)] //[DataType(DataType.Currency)] public decimal Price { get; set; } 有人可以告诉我,我怎么能做到这一点? 现在我将接受任何工作方法。