本文介绍了如何在MVC 4中的view.cshtml上使用if ... else语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< body>



客户ID为<%= Model.Id%>



客户代码是<%= Model.CustomerCode%>



<%if(Model.Amount> 100){%>

这是一个骄傲的客户

<%} else {%>

这是普通客户

<%}%>

< / body>



如果我们将@替换为百分比标签,那么它也不起作用。我也尝试@ {},但它不起作用。编辑此代码。

<body>

The customer id is <%= Model.Id %>

The customer Code is <%= Model.CustomerCode %>

<% if (Model.Amount > 100) {%>
This is a priveleged customer
<% } else{ %>
This is a normal customer
<%} %>
</body>

if we replace @ for percentage tag then its also don't works. i also try @{} but its not work. edit this code.

推荐答案

The customer id is @Model.Id
 
The customer Code is @Model.CustomerCode
 
@if (Model.Amount > 100)
{
    <p>This is previledge customer</p>
}
else
{
    <p>This is normal customer</p>
}





或ASPX引擎如下 -



or for ASPX engine as below -

The customer id is <%= Model.Id %> 

The customer Code is <%= Model.CustomerCode %> 

<% if (Model.Amount > 100) {%>
This is a priveleged customer
<% } else{ %>
This is a normal customer
<% } %>


"# if(condition == true) { #" + "<input type='button' onclick='someEvent' value='' />" +
"# } else { #" +
 "Do some action"
"# } #"





它应该在MVC-4中工作



It should work in MVC-4


这篇关于如何在MVC 4中的view.cshtml上使用if ... else语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 00:30