1

I searched all around, but could not find any reasonable explanation.

I found <%: tag in one of the projects. It works like the <%= tag.

I could not find any description on this tag I only found that <%: and <%= are the same.

So the question popped out, why could there be two different tags with same functionality? I think there should be some difference.

Could you please clarify it for me.

Thank you

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
To Ka
  • 640
  • 8
  • 24

3 Answers3

2

<%: Performs a HTML Encode on the string you are writing out

Scott Hanselman suggests thinking about the equals sign being closed - like a gate (side on view). He talks about it in this video

ASP.NET MVC 2: Ninja Black Belt Tips

Matt
  • 3,664
  • 3
  • 33
  • 39
1

<% %> are Embedded Code Blocks

and

<%= %> are used to Display content from web page.

Moreover you can find all the details about ASP.NET Page Syntax from here.

Hope this helps!!

huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99
0

According to this blog post it is a new feature introduced in ASP.NET 4. It is used to automatically HTML Encode the output.

I suggest to read the full blog post, to see how it works ;)

Luzik
  • 276
  • 3
  • 8