30

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

marshally
  • 3,475
  • 2
  • 22
  • 26

4 Answers4

73

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
  • 380,066
  • 110
  • 546
  • 781
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
  • 54,910
  • 30
  • 111
  • 164
2

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

BC.
  • 23,138
  • 12
  • 46
  • 62
2

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

<%# x %> indicates a databind.

<% %> indicates server-executable code.

Yes - that Jake.
  • 16,218
  • 14
  • 70
  • 95