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

前端 未结 1 613
情话喂你
情话喂你 2021-01-07 23:02

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.

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-07 23:27

    In your Razor View cshtml:

    @if(Model.RevealSecretPlans)
    {
        
    Giant frikkin laser
    }

    This of course assumes RevealSecretPlans is a boolean

    0 讨论(0)
提交回复
热议问题