ASP.NET MVC 2 Calling html helper inside if conditional statement
I'm having a problem getting the syntax correct. The html helper returns true or false.
<开发者_开发百科;% if (<%= Html.SecurityTrim("Admin")%>) { %>
<span>Only for accounting</span>
<% } %>
What do I need to change to get this to compile correctly?
Supposing that Html.SecurityTrim()
returns bool
,
<% if ( Html.SecurityTrim("Admin") ) { %>
<span>Only for accounting</span>
<% } %>
Sounds like your Html.SecurityTrim()
returns a bool.
In this case, then no need to escape out of code, just use it as your condition to test.
<% if (Html.SecurityTrim("Admin")) { %>
<span>Only for accounting</span>
<% } %>
精彩评论