.net mvc Razor 三元运算判断赋值 ?:
预期效果:
当Model中的Age数字列值为0时,不显示该值。
<input type="text" class="form-control onlyPositiveNumber" id="Age"
maxlength="3" style="text-align:right;width:80px; " value='@(Model.Age == 0? "":Model.Age.ToString())' >
预期效果:
根据ViewData中的值,判断radio是否需要被选中
<input type="radio" id="rdoReportTypeBS" name="ReportType" disabled="disabled" value="BS"
@(ViewData["ReportType"].ToString().ToUpper() == "BS"?"checked":"") >
posted on 2017-12-26 16:31 freeliver54 阅读(1196) 评论(1) 编辑 收藏 举报