How to hide a div element depending on Model value? MVC

前端 未结 3 1144
情书的邮戳
情书的邮戳 2020-12-09 00:57

Here is what I have at the moment

 hidden=\"@(Model.IsOwnedByUser||!Model.CanEdit)\"

This works fine on Chrome but doesnt hide on Internet

3条回答
  •  有刺的猬
    2020-12-09 01:43

    The below code should apply different CSS classes based on your Model's CanEdit Property value .

    Some links

    But if it is something important like Edit/Delete links, you shouldn't be simply hiding,because people can update the css class/HTML markup in their browser and get access to your important link. Instead you should be simply not Rendering the important stuff to the browser.

    @if(Model.CanEdit)
    {
      
    Edit/Delete link goes here
    }

提交回复
热议问题