We have been using <%=...%> as a standard expression scripts. with the advent of ASP MVC we are introducing <%: ..%>.
What’s the difference between following asp neggets:
<%: ViewData["Key"] %> and <%=ViewData["Key"] %>
I tried to search on it but didn’t find any results..
Regards,
Sumeet
is a new syntax in .NET 4.0, which is basically the same as:
So it’s a quick way to encode strings, shown in the view.
The reason you should use it, is to prevent Html-codes being injected in user-input.
For more info check this blog post by Scott Guthrie: 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