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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
IHtmlStringinterface.