. So far i\'ve seen <%: %>, <%=" />
开发者

asp.net Output Encoding?

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 开发者_如何学JAVAhelp 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜