如何在Razorview
中为用户输入添加税额这是当前代码
<div class="form-group">
@Html.LabelFor(model => model.Price, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@{
double tax = 12.5;
}
@Html.EditorFor(model => model.Price * tax, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Price, "", new { @class = "text-danger" })
</div>
</div>
然而这不起作用,请帮助我
答案 0 :(得分:3)
我会在我的模型中创建一个返回包含税价的房产。
public class model
{
public decimal Price { get; set; }
public decimal PriceWithTax
{
get
{
return Price * 1.125m;
}
}
}