Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Razor中向用户输入添加税_C#_Asp.net_Html_Razor - Fatal编程技术网

C# 在Razor中向用户输入添加税

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; }

如何在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>

@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;
        }
    }
}

实际上,当我运行此代码时,应用程序崩溃-因此,如果我键入了错误的代码,我需要帮助。实际上,当我运行此代码时,应用程序崩溃-因此,如果我键入了错误的代码,我需要帮助。