Razor---服务器端标记语言

时间:2021-06-04 14:37:01
Razor 是一种允许您向网页中嵌入基于服务器的代码(Visual Basic 和 C#)的标记语法
<ul>
@for (int i = 0; i < 10; i++) {
<li>@i</li>
}
</ul>

<select >
@if (ViewBag.userList != null && ViewBag.userList.Count > 0)
{
foreach (var item in ViewBag.userList)
{

<option value="@item.UserId">@item.RealName - @item.Account</option>
}
}
</select>

@switch(day)
{
case "Monday":
message="This is the first weekday.";
break;
case "Thursday":
message="Only one day before weekend.";
break;
case "Friday":
message="Tomorrow is weekend!";
break;
default:
message="Today is " + day;
break;
}
<p>@message</p>