List of what each of <% means (<%#, <%=, etc…)

Possible Duplicate:
ASP.NET “special” tags

You know how you can embed property value from code-behind in your page by simply using <%= PropertyFromCodeBehind %> in your .aspx?

Well, I only recently discovered that and I can’t seem to find any tutorial that would explain this (and related stuff) in more depth (I only know that <%# is used in conjuction with Eval) – probably because I’m using <% for searches.

So, can anybody provide me with more detail explanation of these tags, or give a link to some tutorial that explains all this? I’m interested in anything that can be learned on this subject; somewhere I saw that you can do fancy stuff like <% for … %>.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Here is a good place to get started.

There are several different syntaxes:

  • <%$ %> Expression Syntax
  • <%# %> Data-Binding syntax
  • <% %> Evaluated Code Blocks
  • <%= %> Statement and Expression

New to ASP.NET 4 is the HTML encoding syntax (haacked). This is the same as <%= %> except the result is HTML encoded (for non IHtmlString types). The new syntax is intended to replace <%= %>.

  • <%: %> HTML Encoded output

Method 2

See ScottGU’s post post to get you started.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x