首页 > 解决方案 > 从 C# 将布尔值传递给 View

问题描述

如何传递boolean值进行检查。

下面是我的代码

模型:

[JsonProperty("boolean")]
public bool? boolean{ get; set; }

看法:

bool test = (ViewBag.boolean== null) ? false : (bool)ViewBag.boolean;

if (test == true)
{
    <button type="submit" id="xxxx" class=""></button>
}

boolean是从Json Api存储真假,但无法调用boolean值进行检查,任何人都可以提供建议吗?谢谢!

标签: c#

解决方案


推荐阅读