A coworker recently checked in a changeset where lots of expressions on the form <%= (...) %> were changed to <%: (...) %>.
I have a vague recollection of having heard what <%: does, but cannot remember. It's too late in the night to call my coworker, and Google and Bing both seem unable to search for the string "<%:".
Can someone enlighten me, please?
It HtmlEncodes the string, if it hasn't already been encoded.
The "hasn't already been encoded part" is why MvcHtmlString was introduced. MVC2 returns MvcHtmlString from many HtmlHelper methods to represent strings that should not be re-encoded. The <%: %> knows not to re-encode.
See What is an MvcHtmlString and when should I use it? for a good discussion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With