![](/img/trans.png)
[英]How do I maintain my menu, and footer in the same place while horizontal scrolling?
[英]How do I maintain 1 decimal place while monitoring the change on an array of textboxfor / editorfor?
TextBoxFor調用我的函數,但不更改我的十進制顯示值(2.645844)。
EditorFor將我的值設置為小數點后一位(2.6),但不調用我的函數。
我的模型中具有以下屬性:
[DisplayFormat(DataFormatString = "{0:N1}", ApplyFormatInEditMode = true)]
public decimal AttritionRate { get; set; }
在更改事件中,我需要運行一個重新計算函數:
@for (int i = 0; i < Model.Positions.Count(); i++)
{
@Html.TextBoxFor(p => p.Positions[i].AttritionRate, new { type = "number", onkeyup = "updateBigTotal(" + i + "," + Model.Positions[i].AttritionRate + ")" })
}
然后在javascript中調用以下代碼:
function updateBigTotal(arraypos, oldValue) {
var newvalue = parseFloat($('#Positions_' + arraypos + '__AttritionRate').val());
... go on to perform calculations
}
我如何實現兩者?
經過幾天的掙扎,這似乎行得通:
@Html.TextBoxFor(p => p.Positions[i].AttritionRate, "{0:n1}", new { type = "number", onkeyup = "updateBigTotal(" + i + "," + Model.Positions[i].AttritionRate + ")" })
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.