MVC3剃刀Html.TextBoxFor计算字段 [英] MVC3 Razor Html.TextBoxFor Calculated Fields

查看:141
本文介绍了MVC3剃刀Html.TextBoxFor计算字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最后,我想有一个像重量*价格计算领域。

Ultimately I would like to have calculated fields like Weight * Price.

假设我有我的看法MVC3:

Suppose I have in my MVC3 view:

    @Html.TextBoxFor(modelItem => item.Package.USDKg)
    @Html.HiddenFor(modelItem => item.Pricing.VolumePrice)

我是否能直接计算这些?或诉诸JQuery的?
我真的想使定价隐藏甚至如果可能的话源视图。

Am I able to calculate these directly? Or resort to JQuery? I would really like to keep pricing "hidden" even in source view if possible.

基本上,当用户输入他们的包装重量,价格将显示(计算关闭隐藏价格点值)。

Basically, when a user enters their package weight, a price would be displayed (calculated off of hidden price point values).

感谢您的指点。

推荐答案

有一个剃须刀,你可以做一个逻辑刚内标记了!

Having a razor, you could do a logic just inside the mark up!

@{
   var value = model.Item.Value;
   var price = model.Item.Proce;
   var calculated = value * price;
}

<div class="price>Your price: @calculated</div>

更多信息是在这里:

More info is here:

http://weblogs.asp.net/ scottgu /存档/ 2010/07/02 /引入-razor.aspx

这篇关于MVC3剃刀Html.TextBoxFor计算字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆