Linking with the page <% on.aspx

Is there any difference between doing the binding on the .aspx page via <% # some code%> and <% = some code%>?

Example:

VS

Thanks. -Igor

+4
source share
2 answers

<%# %> used in binding expressions. Just when 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 runtime value of an expression.

<%= expression %> equivalent to <% Response.Write(expression); %> <% Response.Write(expression); %> , which is executed at the visualization stage and directly displays the value of the expression. As a result, it cannot be used to change the behavior of objects on the server side.

+6
source

<%= %> is the equivalent of Response.Write();

<%# %> intended for data binding when calling .DataBind();

+1
source

All Articles