A new feature in ASP.NET 4: Shorthand syntax for Html Encoding

So far if we need to HTML encode content that we throw out to the response stream we will use Server.HtmlEncode() method as below.

<%= Server.HtmlEncode(“Content”) %>

Now in ASP.NET 4 we have a new code syntax, which comes handy whenever you want to emit content with HTML encoding, the new syntax is <%: … %> the “=” character is replaced in this new syntax by the “:” character, as shown below.

<%: “Content” %>
Bookmark / Share

Comments for this entry..

Write your comment..




biuquote
  • Comment
  • Preview
Loading