【发布时间】:2015-05-21 02:43:34
【问题描述】:
大家好,我想在 aspx 页面中使用三元运算符。我的 aspx.cs 文件中有两个公共变量,如下所示
public string currency = "INR";
public decimal amount = 100;
我想根据我的货币来构建html标签,目前我正在这样做
<% if (currency != "INR")
{%>
<span>$<%=amount%></span>
<%}
else
{ %>
<span<%=amount%></span>
<%} %>
我想做一行
<span><% if (currency != "INR") %> $ amout <% : %> </span>
但是我收到了Invalid expression term ':' 的错误,所以如果可能的话,有人可以帮助我
【问题讨论】:
标签: c# asp.net ternary-operator