Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between <%: item["Title"] %> and <%= item["Title"] %> [duplicate]

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"] %>

?

like image 932
Pradip Bobhate Avatar asked Mar 04 '11 18:03

Pradip Bobhate


1 Answers

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

<%: item["Title"] %>

is equivalent to

<%= Html.Encode(item["Title"]) %>  
like image 163
Justin Niessner Avatar answered Sep 20 '22 21:09

Justin Niessner