Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does mean ":" in <%: and what is the difference to <%=?

In ASP.NET MVC 2 <%: tag was introduced to replace <%= for Html helpers. But what does it mean and what is the difference to the previous one? When shall I use <%= and when <%:?

Thank you

like image 277
Fabiano Avatar asked Aug 25 '10 14:08

Fabiano


1 Answers

In ASP.NET 4 the <%: xyz %> syntax will do the same thing as <%= Server.HtmlEncode(xyz) %> did in previous versions. It is simply a shortcut because it is used so often.

As Richard says below, it can also determine if a string does not need to be encoded based on whether or not it implements the IHtmlString interface.

like image 79
Joe Phillips Avatar answered Nov 09 '22 18:11

Joe Phillips