<p>Can I get a 'when to use' for these and others? </p>

<pre><code>&lt;% %&gt;
&lt;%# EVAL() %&gt;
</code></pre>

<p>Thanks</p>

[{'answer_id': 28225, 'author': 'bdukes', 'author_id': 2688, 'author_profile': 'https://Stackoverflow.com/users/2688', 'pm_score': 5, 'selected': True, 'text': '<p>Check out the <a href="http://quickstarts.asp.net/QuickStartv20/aspnet/doc/pages/syntax.aspx#expressions" rel="noreferrer">Web Forms Syntax Reference</a> on MSDN.</p>\n\n<p>For basics, </p>\n\n<ul>\n<li><p>&lt;% %> is used for pure code blocks.  I generally only use this for if statements</p>\n\n<blockquote>\n  <br/>\n    &nbsp; &lt;div class="authenticated"><br/>\n    <br/>\n    &nbsp; &lt;div class="unauthenticated"><br/>\n    \n</blockquote></li>\n<li> is used to add text into your markup; that is, it equates to \n\n<blockquote>\n  <p>&lt;div class=\'&lt;%= IsLoggedIn ? "authenticated" : "unauthenticated" %>\'></p>\n</blockquote></li>\n<li><p>&lt;%# Expression %> is very similar to the above, but it is evaluated in a DataBinding scenario.  One thing that this means is that you can use these expressions to set values of runat="server" controls, which you can\'t do with the &lt;%= %> syntax.  Typically this is used inside of a template for a databound control, but you can also use it in your page, and then call Page.DataBind() (or Control.DataBind()) to cause that code to evaluate.</p></li>\n</ul>\n\n<p>The others mentioned in the linked article are less common, though certainly have their uses, too.</p>\n'}, {'answer_id': 28227, 'author': 'Brian Warshaw', 'author_id': 1344, 'author_profile': 'https://Stackoverflow.com/users/1344', 'pm_score': 2, 'selected': False, 'text': '<p>You can also use</p>\n\n<p><code>&lt;%= Class.Method() %&gt;</code></p>\n\n<p>And it will print the result, just as you can do in Ruby on Rails.</p>\n'}, {'answer_id': 28263, 'author': 'chakrit', 'author_id': 3055, 'author_profile': 'https://Stackoverflow.com/users/3055', 'pm_score': 2, 'selected': False, 'text': '<p>Just want to add, there\'s also the resources expression</p>\n\n<pre><code>&lt;%$ Resources:resource, welcome%&gt;\n</code></pre>\n\n<p>and asp.net would look for localized version of "welcome" in satellite assemblies automatically.</p>\n'}, {'answer_id': 8488412, 'author': 'sevenkul', 'author_id': 931378, 'author_profile': 'https://Stackoverflow.com/users/931378', 'pm_score': 1, 'selected': False, 'text': '<p>In ASP.NET 4.0, comes &lt;%: %> syntax for writing something html encoded.</p>\n\n<pre><code>&lt;%: "&lt;script&gt;alert(\'Hello XSS\')&lt;/script&gt;" %&gt;  \n</code></pre>\n\n<p>The above can be used instead of the belove.</p>\n\n<pre><code>&lt;%= Html.Encode("&lt;script&gt;alert(\'Hello XSS\')&lt;/script&gt;")%&gt;  \n</code></pre>\n'}]
['https://Stackoverflow.com/questions/28219', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1293/']