Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Partial answer</p> <p>quoted from Mike Banavige</p> <blockquote> <p>&lt;% %> An embedded code block is server code that executes during the page's render phase. The code in the block can execute programming statements and call functions in the current page class. <a href="http://msdn2.microsoft.com/en-gb/library/ms178135(vs.80).aspx" rel="nofollow noreferrer">http://msdn2.microsoft.com/en-gb/library/ms178135(vs.80).aspx</a></p> <p>&lt;%= %> most useful for displaying single pieces of information. <a href="http://msdn2.microsoft.com/en-us/library/6dwsdcf5(VS.71).aspx" rel="nofollow noreferrer">http://msdn2.microsoft.com/en-us/library/6dwsdcf5(VS.71).aspx</a></p> <p>&lt;%# %> Data Binding Expression Syntax. <a href="http://msdn2.microsoft.com/en-us/library/bda9bbfx.aspx" rel="nofollow noreferrer">http://msdn2.microsoft.com/en-us/library/bda9bbfx.aspx</a></p> <p>&lt;%$ %> ASP.NET Expression. <a href="http://msdn2.microsoft.com/en-us/library/d5bd1tad.aspx" rel="nofollow noreferrer">http://msdn2.microsoft.com/en-us/library/d5bd1tad.aspx</a></p> <p>&lt;%@ %> Directive Syntax. <a href="http://msdn2.microsoft.com/en-us/library/xz702w3e(VS.80).aspx" rel="nofollow noreferrer">http://msdn2.microsoft.com/en-us/library/xz702w3e(VS.80).aspx</a></p> <p>&lt;%-- --%> Server-Side Comments. <a href="http://msdn2.microsoft.com/en-US/library/4acf8afk.aspx" rel="nofollow noreferrer">http://msdn2.microsoft.com/en-US/library/4acf8afk.aspx</a></p> </blockquote> <p>Update:</p> <p>Okay this appears to work</p> <pre><code>&lt;asp:Label ID="MyLabel" runat="server" Text='&lt;%# MyProperty%&gt;'&gt;&lt;/asp:Label&gt; </code></pre> <p>If I use the eval syntax then I get an error about databound control or I use the &lt;% then I get a server side controls error. Any more color appreciated.. not sure I really understand what is going on.</p> <p>Perhaps it has something to do with the render phase.</p> <p>Few more observations:</p> <p>I can use &lt;%= without databinding and get the property value but can not use it in a server side control without getting error.</p> <p>If I use &lt;%# in server side control but I'm required to do a Page.Databind.</p> <p>Interestingly, I can use either &lt;%= or &lt;%# when I want to render text that is not inside a control. Although the latter requires databinding.</p> <p>The new &lt;%: syntax is explained, also called code expression syntax </p> <blockquote> <p>With ASP.NET 4 we are introducing a new code expression syntax (&lt;%: %>) that renders output like &lt;%= %> blocks do – but which also automatically HTML encodes it before doing so.</p> </blockquote> <p><a href="http://weblogs.asp.net/scottgu/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2" rel="nofollow noreferrer">http://weblogs.asp.net/scottgu/new-lt-gt-syntax-for-html-encoding-output-in-asp-net-4-and-asp-net-mvc-2</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload