In <% you can put any code in there, dim variables, whatnot.
In <%= that's actually short for response.write, so you are limited to an
expression.
In <%# this is a databinding expression used inside the scope of a web
control (such as <asp:Repeater ) where you have a Container to use to access
the items you've bound to that particular control. What you can expose is a
DataItem -- which are your value pairs. ie <%#
DataBinder.Eval(Container.DataItem, "Name") %>
Like <%= you must supply an expression, you cannot write any code in these
blocks. If you don't use the Container class, then it's the same as saying
<%= only you're using up more resources to create the Container you didn't
use.
And of course, if you need some more code in this block, just simply write a
function that returns exactly the string you want to show:
<%# GetMyText(Container.DataItem, "Name") %>
Unfortunately, using the <%# is a late bound operation, so you're getting
ASP like performance from an ASP.NET application. Not a big deal normally,
it's still superfast, but this would be the place to look if you ever start
having performance issues.
-Max