user2284341
user2284341

Reputation: 671

Html helper syntax

I'm working on an MVC project without Razor. Therefore Html helpers are wrapped in <% and %>.

My question is what are the differences between <%= and <%: ?

Upvotes: 1

Views: 109

Answers (1)

Arghya C
Arghya C

Reputation: 10078

<%= creates html markup - renders html elements in page <%: encodes as display text on page

So, if you put a anchor inside <%:this%> you'll see the raw markup in your page rather than a link. And by the way, in Razor, why not use @ instead of <%=

e.g. the following code produces the page below

<div>
    <%= "<a href='#'>test</a>" %>
    <%: "<a href='#'>test</a>" %>
</div>

enter image description here

Upvotes: 3

Related Questions