条件编译在剃刀关闭? [英] Conditional Compilation is turned off in Razor?

查看:138
本文介绍了条件编译在剃刀关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#foreach循环即输出一些JavaScript来初始化我的Razor视图一些进度条。

I've got a c# foreach loop that Is outputting some javascript to initialize some progress bars on my razor view.

@foreach (var item3 in Model)
{
    @:$("#campaignMeter-@item3.ID").wijprogressbar({ value: @((item3.TotalRedeemed / item3.TotalSold) * 100), fillDirection: "east" });

}

我遇到的问题是Visual Studio是报告条件编译已关闭的foreach循环,而且,对于价值的计算量小总是被说成0,尽管并TOTALREDEEMED有TotalSold值。我使用了@:操作者正确?感谢您的帮助。

The problem I'm having is visual studio is reporting "Conditional Compilation is Turned Off" on the foreach loop, and the small calculation for value is always coming out as 0, despite TotalRedeemed and TotalSold having values. Am I using the @: operator properly? Thanks for your help.

我到目前为止已经试过两项建议,这就是我目前有:

I've tried both suggestions so far and this is what I currently have:

 @foreach (var item3 in Model)
 {

     var percentage = (item3.TotalRedeemed / item3.TotalSold) * 100;

     <text>$("#campaignMeter-@item3.ID").wijprogressbar({ value: @percentage, fillDirection: "east" });</text>

 }

百分比现身为0,但并TOTALREDEEMED有TotalSold价值观,因为它们是印在视图在此之前被调用。有没有一种方法来设置我的看法一个破发点看到的是它的打印之前多大比例?

percentage is coming out as 0, but TotalRedeemed and TotalSold have values, as they are printed on the view before this is called. Is there a way to set a break point on my view to see what percentage is before its printed?

推荐答案

添加 / * @ cc_on @ * / 在code。

更新:找到了原因,他们可能是 0

Update: Found out why they could be 0:

item3.TotalRedeemed item3.TotalSold 必须浮动双击。如果他们是 INT ,它出来到 0

item3.TotalRedeemed and item3.TotalSold need to be float or double. If they are int, it comes out to 0.

这篇关于条件编译在剃刀关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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