7

Possible Duplicate:
Are <%: and <%= the same thing as embbed code (expression) blocks

I am developing an ASP.NET MVC 2 application using .NET 4.0. Just wanted to know, what is the difference between

 <%: item["Title"] %>

and

 <%= item["Title"] %>

?

Community
  • 1
  • 1
Pradip Bobhate
  • 235
  • 1
  • 2
  • 10

1 Answers1

22

The first will automatically HTML Encode the value. The second won't.

<%: item["Title"] %>

is equivalent to

<%= Html.Encode(item["Title"]) %>  
Justin Niessner
  • 242,243
  • 40
  • 408
  • 536