Razor - 三目运算符样例

Razor语法下,三目运算符(cond?exprForTrue:exprForFalse)样例

Razor - 三目运算符样例

example1

1
<input type="text" value="@(Model.PName == null?"":Model.PName)" />

example2

1
2
<a class="btn btn-primary @(Model.HasPDF ? "" : " disabled")" 
href="@Url.Action("DownloadPDF", routeValues: new {ID = Model.QuotationID})">PDF</a>