In general, <%#..%>
is used for preprocessing a template, such as when databinding, whereby the names of properties of the objects are not known at compile-time. If, for example, you have an ASP.NET Repeater object, and you databind a list of objects to it, this notation is used to pre-populate values that could not be set at any point except during the databind lifecycle.
The other notations, <%..%>
and <%=..%>
are more standard and you'll see these far more often than the other syntax previously discussed, especially if you use something like ASP.NET MVC instead of ASP.NET Web Forms. The syntax <%..%>
executes arbitrary script inline, and nothing more, but allows you to write entire blocks of .NET code such as if statements, while loops, for loops, etc. The syntax <%=..%>
is an evaluate-and-write syntax, and is rough equivalent of <% Response.Write([..].ToString()) %>
. I.e., <%= myVal %>
is the same as <% Response.Write(myVal.ToString()) %>
These syntaxes are basic ASP.NET knowledge.