gpt4 book ai didi

c# - 如何使@Html.CheckBoxFor 不可见?

转载 作者:太空宇宙 更新时间:2023-11-03 11:18:51 25 4
gpt4 key购买 nike

如何使用 htmlAttributes 使 @Html.CheckBoxFor 不可见?

我试过:

   @Html.CheckBoxFor(modelItem => modelItem.DeleteEnabled, new {visible= @modelItem.Visible})

最佳答案

你可以这样尝试:

@Html.CheckBoxFor(modelItem => modelItem.DeleteEnabled, 
new { style = modelItem.Visible ?
string.empty :
"display:none"})

或者如果您在页面源代码中根本不需要它,甚至不需要隐藏它,则使用 @if 例如:

@if(modelItem.Visible)
{
@Html.CheckBoxFor(modelItem => modelItem.DeleteEnabled)
}

关于c# - 如何使@Html.CheckBoxFor 不可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11721646/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com