简体   繁体   中英

ASP.NET server tag with colon?

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

<%: 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

<% %> 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!!

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 ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM