How to use ASP.NET <%= tags in server control attributes?

后端 未结 7 1522
陌清茗
陌清茗 2020-11-28 10:15

This works:

\" />

This doesn\'t work:

         


        
7条回答
  •  抹茶落季
    2020-11-28 10:57

    Just pitching this little nugget in for those who want a good technical breakdown of the issue -- https://blogs.msdn.microsoft.com/dancre/2007/02/13/the-difference-between-and-in-asp-net/

    I think the crux is in pretty decent agreement with the other answers:

    • The <%= expressions are evaluated at render time
    • The <%# expressions are evaluated at DataBind() time and are not evaluated at all if DataBind() is not called.
    • <%# expressions can be used as properties in server-side controls. <%= expressions cannot.

提交回复
热议问题