Here is what I have at the moment
hidden="@(Model.IsOwnedByUser||!Model.CanEdit)"
This works fine on Chrome but doesnt hide on Internet Explorer
I tried also visibility set false but no luck.
then I found out another style as below
style="@(Model.IsOwnedByUser||!Model.CanEdit)?'display:none'""
I could not get it worked. What is the correct format to hide an element with Razor syntax?
Or I would use Jquery to hide the element. but is it actually possible print out jquery statement that would hide the element on page load?
This question is related to
jquery
html
asp.net-mvc
razor
Your code isn't working, because the hidden attibute is not supported in versions of IE before v11
If you need to support IE before version 11, add a CSS style to hide when the hidden attribute is present:
*[hidden] { display: none; }
Try:
<div style="@(Model.booleanVariable ? "display:block" : "display:none")">Some links</div>
Use the "Display" style attribute with your bool model attribute to define the div's visibility.
Source: Stackoverflow.com