32

In ASP.Net, what is the difference between <%= x %> and <%# x %>?

marshally
  • 3,541
  • 2
  • 23
  • 26

4 Answers4

76

See this question:
When should I use # and = in ASP.NET controls?


Summary from those answers:

There are a several different 'bee-stings':

Community
  • 1
  • 1
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
5

<%# is data binding expression syntax.

<%= resolves the expression returns its value to the block (Embedded code block reference) - effectively shorthand for <% Response.Write(...); %>

Daniel Schaffer
  • 56,753
  • 31
  • 116
  • 165
2

<%# is the databinding directive, <%= is a shortcut for "Response.Write"

BC.
  • 24,298
  • 12
  • 47
  • 62
2

<%= x %> is shorthand for Response.Write()

<%# x %> indicates a databind.

<% %> indicates server-executable code.

Yes - that Jake.
  • 16,725
  • 14
  • 70
  • 96