【发布时间】:2014-01-04 07:20:23
【问题描述】:
我正在尝试根据 if 语句在 Razor 视图中启用或禁用 html 按钮。无论 if 语句的值如何,这都会禁用按钮。
@{
disabled = "";
if (Model.User.PublicId == ViewBag.SiteUser.PublicId)
{
followClass += " you";
followText = "You";
disabled = "disabled";
}
}
<button class="@followClass" disabled="@(disabled)">@(followText)</button>
【问题讨论】:
-
顺便说一句,你可以去掉所有这些括号。
标签: html asp.net asp.net-mvc asp.net-mvc-4 razor