C# 在Razor中向用户输入添加税
如何在Razorview中向用户输入添加纳税值 这是当前代码C# 在Razor中向用户输入添加税,c#,asp.net,html,razor,C#,Asp.net,Html,Razor,如何在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; }
<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>
@LabelFor(model=>model.Price,htmlAttributes:new{@class=“controllabel col-md-2”})
@{
双重税=12.5;
}
@EditorFor(model=>model.Price*tax,new{htmlAttributes=new{@class=“form control”}})
@Html.ValidationMessageFor(model=>model.Price,“,new{@class=“text danger”})
但是这不起作用,请帮助我,我会在我的模型中创建一个返回含税价格的属性
public class model
{
public decimal Price { get; set; }
public decimal PriceWithTax
{
get
{
return Price * 1.125m;
}
}
}
我会在我的模型中制作一个返回含税价格的属性
public class model
{
public decimal Price { get; set; }
public decimal PriceWithTax
{
get
{
return Price * 1.125m;
}
}
}
实际上,当我运行此代码时,应用程序崩溃-因此,如果我键入了错误的代码,我需要帮助。实际上,当我运行此代码时,应用程序崩溃-因此,如果我键入了错误的代码,我需要帮助。