tags:

views:

74

answers:

2
+3  A: 

<%: is a new way to automatically HTML encode your data. Article from Haacked on it. New to .NET 4.0.

Dustin Laine
Important to note is that you opt-out of HTML encoding by passing it an `IHtmlString` (i.e. something that says it knows how to create valid HTML). They're saying that `<%: %>` should entirely replace `<%= %>`.
bdukes
Good addition!!
Dustin Laine
+3  A: 
<%: "some string" %>

is equal to:

<%= Html.Encode("some string") %>
šljaker
wow, cool, i did not know that.
Gabriel
yes, but `<%: someMvcHtmlString %>` will not be the same as `<%= Html.Encode(someMvcHtmlString) %>` but instead will Asp.net MVC recognize the `MvcHtmlString` and avoid double encoding. Actually, `IHtmlString` in general.
lasseespeholt
@lasseespeholt, you are correct. Here's another article for the new Html encoding output syntax: http://weblogs.asp.net/scottgu/archive/2010/04/06/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2.aspx
šljaker