219

I've programmed in both classic ASP and ASP.NET, and I see different tags inside of the markup for server side code.

I've recently come across a good blog on MSDN that goes over the difference between:

  • <%= (percentage together with equals sign) and
  • <%# (percent sign and hash/pound/octothorpe)

(<%# is evaluated only at databind, and <%= is evaluated at render), but I also see:

  • <%$ (percent and dollar sign) and
  • <%@ (percent sign and at symbol).

I believe <%@ loads things like assemblies and perhaps <%$ loads things from config files? I'm not too sure.

I was just wondering if anyone could clarify all of this for me and possibly explain why it's important to create so many different tags that seemingly have a similar purpose?

Anthony Mastrean
  • 21,032
  • 20
  • 99
  • 180
Aaron
  • 7,291
  • 12
  • 34
  • 37

2 Answers2

310
Maris B.
  • 2,189
  • 3
  • 20
  • 34
Jose Basilio
  • 49,569
  • 12
  • 117
  • 116
  • I guess it's because it's an accepted answer, but trying to edit /w the link didn't work. here's the link I tried putting in about the " – John MacIntyre Sep 15 '11 at 21:32
  • Awesome! I know this is old but I have been looking all over the internet for this info the last 2 days. Thanks! – jdbosley Jul 25 '14 at 16:16
  • 7
    Is there a name for all these? What are these called as a group? – Vippy Feb 26 '15 at 18:25
  • 9
    @Vippy They are called *bee stings*. – Ian Boyd Jun 30 '15 at 18:46
  • @IanBoyd Where does the term *bee stings* come from? – user692942 Mar 15 '16 at 13:27
  • 1
    @Lankymart Earliest usage i can find is [September 2008](http://stackoverflow.com/a/115212/12597) – Ian Boyd Mar 15 '16 at 19:39
  • Maybe my testing method sucks, but I can't see a difference between and . Both of them HTML encode the value. – Dan Jameson May 23 '16 at 03:39
  • @DanJameson Many ASP.Net controls (e.g. TextBox) automatically HTML Encode their contents. If you try outputting a value directly to the page, or even a Label, you'll see the difference between `` and ``. – Benjamin Ray Feb 28 '17 at 14:47
  • 1
    @Vippy MS calls them [Embedded code blocks](https://msdn.microsoft.com/en-us/library/ms178135.aspx) "Bee stings" is an unofficial term. – shiggity Apr 25 '17 at 14:01
5

You've covered 2 of them (<%# is evaluated only at databind, and <%= is evaluated at render), and the answer for "<%@" is that it's compiler directives (ie., stuff like what you'd put on a compiler's command line).

I don't know about "<%$".

Michael Burr
  • 321,763
  • 49
  • 514
  • 739