1

I'm not even sure i'm calling this the right thing. I'm just starting to get into ASP.Net and of course i'm starting to see syntax like <% "Code here" %>. So far i've seen <%: %>, <%= %>, <%# %>. Of course google doesn't like these symbols for searching so searching for help is futile :). Maybe this type of syntax is back from classic ASP (which i never used)? I don't know if there are any others than what i listed. Does anyone have a good link or can write up a good explanation. I also think it used in XML literals for vb.net. I also think its associated with certain functions like the "Eval" function.

1 Answer 1

3

To be short,

  • <%# %> is used for data binding (for example in a ListView where you want to specify how elements must be displayed on a page). If this.Page.DataBind() (or control-level binding) is not called, nothing will be displayed.

  • <%= %> is used to display any string. <% %> on the other hand would let you to do any stuff you want, but you must use Response.Write() to output something.

  • <%: %> is a new feature in .NET Framework 4.0 which does the same thing as <%= %>, but encodes output to be displayed as HTML.

This is called inline tags, so searching for "asp.net inline tag" may give you additional info.

Sign up to request clarification or add additional context in comments.

1 Comment

@je5: yes, there are: <%-- --%> comment syntax, <%@ %> directives and the very strange <%$ %> used for expressions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.