what is <%# %> and its relationship with Eval?

  • Thread starter Thread starter Ryan Liu
  • Start date Start date
R

Ryan Liu

Hi,

I found I can use <% # Contaniner.DateItem.Property.SubProperty%> or <%#
page-variable #>

Why or ( when) we need use <%# Evel("Property")%>? And when to use <%# %>
directly?

The first syntax is even more powerful, can access property of propery.

What really is <#% %>? And what does it enclose? C# code or XML code? What
is its relationship with Eval and Bind, do they depend on each other as
syntax requirement?



Thanks,
Ryan
 
Ryan said:
Hi,

I found I can use <% # Contaniner.DateItem.Property.SubProperty%> or
<%# page-variable #>

Why or ( when) we need use <%# Evel("Property")%>? And when to use <%#
%> directly?

The first syntax is even more powerful, can access property of propery.

What really is <#% %>? And what does it enclose? C# code or XML code?
What is its relationship with Eval and Bind, do they depend on each
other as syntax requirement?

The <%# %> tag is a data binding tag. It has to be inside a control that
is data bound to work fully.

If you are not using it for data bound data, you should use <%= %> instead:

<%= page_variable %>

The server script tags contains C# code (or whatever you use as server
language).

The Eval function is convenient, but it uses reflection to read the
expression from the data item. You will get slightly better performance
if you cast the data item and use the properties instead.
 
Back
Top