I tried to find what the difference is between these two with Google, but I could not find an exact definition, and I could not exactly search for symbols either.
Right now I know that you can put a piece of code between <%# %> and you have to call Page.DataBind() method to apply it, I think this is how <%# %> works. But what does <%= %> mean? When should I use it?
The Basic differences are:
The <%= %>
expressions are evaluated at render time.
The <%# %>
expressions are evaluated at DataBind()
time and are not evaluated at all if DataBind()
is not called.
<%# %>
expressions can be used as properties in server-side controls.
<%= %>
expressions cannot and are used to reference properties or fields.
For example:
<%= Response.Write() %>
<ItemTemplate>
<%# DataBinder.Eval("Title") %>
</ItemTemplate>
You can have a more detailed explanation on msdn here: What's the difference between <%= %> and <%# %>
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With