title: <%: %> brackets for HTML Encoding in ASP.NET 4.0
body: <p>Accidentally I found <a href="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" rel="noreferrer">this post</a> about a new feature in ASP.NET 4.0: Expressions enclosed in these new brackets <code>&lt;%: Content %&gt;</code> should be rendered as HTML encoded. </p>
  
  <p>I've tried this within a databound label in a FormView like so:</p>
  
  <pre><code>&lt;asp:Label ID="MyLabel" runat="server" Text='&lt;%: Eval("MyTextProperty") %&gt;' /&gt;
  </code></pre>
  
  <p>But it doesn't work: The text property contains script tags (for testing), but the output is blank. Using the traditional way works:</p>
  
  <pre><code>&lt;asp:Label ID="MyLabel" runat="server"
      Text='&lt;%# HttpUtility.HtmlEncode(Eval("MyTextProperty")) %&gt;' /&gt;
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>(On a sidenote: I am too stupid to find any information: Google refuses to search for that thing. The VS2010 Online help on MSDN offers a lot of hits, but nothing related to my search. Stackoverflow search too. And I don't know how these "things" (the brackets I mean) are officially called to have a better search term.)</p>
  
  <p>Any info and additional links and resources are welcome!</p>
  
  <p>Thanks in advance!</p>