Is there any difference between performing binding on .aspx page via <%# some code %> and <%= some code %>?
Example:
<%# ResolveUrl("~/default.aspx") %>
VS
<%= ResolveUrl("~/default.aspx") %>
Thanks. -Igor
Is there any difference between performing binding on .aspx page via <%# some code %> and <%= some code %>?
Example:
<%# ResolveUrl("~/default.aspx") %>
VS
<%= ResolveUrl("~/default.aspx") %>
Thanks. -Igor
<%= %>
is the equivalent of Response.Write();
<%# %>
is for databinding when calling .DataBind();
<%# %>
is used in binding expressions. Simply, when a Control.DataBind
is called, the binding expressions will take their actual values. It can be used to set some properties on server controls based on the run time value of an expression.
<%= expression %>
is equivalent to <% Response.Write(expression); %>
which runs on render phase and directly outputs the value of the expression. As a result, it can't be used to modify behavior of server-side objects.