开发者

When using code-behind variables in an ASP.NET page, what is the difference between # and =?

If you are just inserting information on a page, what are the differences, if any, between:

<%#Variable%>

and

开发者_开发问答<%=Variable%>

I've always used the # but a co-worker asked me today and I realized that, as far as I know, they are the same. Surely, though, there must be some difference or why would MS provide both?


<%=Variable%>

is legacy from Classic ASP. Its short for

<% Response.Write(Variable) %>.

A new variation on that is

<%:Variable%>

which handles encoding it to HTML entities.

<%#Variable%>

is used in data binding.


http://naspinski.net/post/inline-aspnet-tags-sorting-them-all-out-(3c25242c-3c253d2c-3c252c-3c252c-etc).aspx

I take no credit for this answer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜