How to show/hide an area within Razor View in ASP.NET MVC programmatically

久未见 提交于 2019-12-01 13:52:43

问题


I want to programmatically show/hide a group of fields (label, textfield, checkbox) on Razor view (.cshtml), based on a model value. The model is access to the view.

Thanks


回答1:


In your Razor View cshtml:

@if(Model.RevealSecretPlans)
{
    <div>
      Giant frikkin laser
    </div>
}

This of course assumes RevealSecretPlans is a boolean



来源:https://stackoverflow.com/questions/6848055/how-to-show-hide-an-area-within-razor-view-in-asp-net-mvc-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!