我想根據if語句在啓用或禁用Razor視圖中的html按鈕之間切換。無論if語句的值如何,都會禁用該按鈕。在Razor視圖中切換禁用按鈕ASP.NET MVC 4
@{
disabled = "";
if (Model.User.PublicId == ViewBag.SiteUser.PublicId)
{
followClass += " you";
followText = "You";
disabled = "disabled";
}
}
<button class="@followClass" disabled="@(disabled)">@(followText)</button>
順便說一句,你可以擺脫所有這些括號的。 – SLaks