I have a view that is using a model. I just need to do a simple subtraction on the model variables using razor.
Here is what the code looks like:
@model Inquiry.Inq_Weights
<table id="mainWeights">
<tr>
<td>@Html.DisplayFor(model => Model.HotScaleHalfId)</td>
<td>@Html.DisplayFor(model => Model.HotScaleGrossWeight)</td>
<td>@Html.DisplayFor(model => Model.HotScaleTareWeight)</td>
</tr>
<tr>
<td><strong>Total Hot Scale Weight</strong></td>
</tr>
<tr>
<td align="right">(@Model.HotScaleGrossWeight - @Model.HotScaleTareWeight;)</td>
</tr>
</table>
I am trying the (@Model.HotScaleGrossWeight - @Model.HotScaleTareWeight;)
but it is just displaying "0 - 0". The zeros are correct at this point. but i don't want it to display the expression, just the result of that operation.
I have also tried using a variable then listing that, as in
@{
var netWeight = @Model.HotScaleGrossWeight - @Model.HotScaleTareWeight;
netWeight;
}
But that doesn't work either. How can I do simple math on model members?