Monday, March 12, 2012

What is the difference between <%# %> and <% %>?

Hi ,

What is the difference between <%# %> and <% %>? When and How should I choose between them?

Thanks
TommyFirst off, it's recommended not to do:
<% %> - - that's the normal code block tags that were in Classic ASP - -

What this means:
<%# %
is a representation of Data received from a dataSource - - in the page_Load routine, if you were hitting a database with a query, you could then add those in each place where you had a field from that query, needing to be displayed.

In ASP - - you'd do the query inline with the code blocks and in ASP.Net, you'd do the query outside your HTML tags, in a sub or function, then, using them, you display the fields.
Hi,

Also take a look @.Data Binding Server Controls

HTH
Inthis thread, Steven Bey gives a nice little summary of the difference between <%= %> and <%# %>.

0 comments:

Post a Comment