<% %> in ASP.NET (embedded code blocks)

后端 未结 5 1346
醉话见心
醉话见心 2021-01-30 13:57

I understand what these signify in the markup of the aspx pages ... but I don\'t not know the full power they can be used for or even the name to denote these special directives

5条回答
  •  北恋
    北恋 (楼主)
    2021-01-30 14:18

    When the server receives a request for an ASPX page, it generates an in-memory class that inherits from Page (or whatever base class you specified). The inherited class translates "normal" markup into static Response.Write() calls, <%...%> into equivalent code, and <%= someExpression %> into Response.Write(someExpression). For the former code block, any valid C# (or VB) should be accepted; for the latter, the embedded code must be a single expression (something you could assign to a variable.

提交回复
热议问题