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

后端 未结 5 1348
醉话见心
醉话见心 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:22

    These are code Block tags.

    And yes you can wrap serverside code in these tags (examples in C#)

    <% if (x = y) {
      } else {
      }
    %>
    

    OR

    <% if (x = y) {%>
       Write this HTML
    <%  } else {%>
       Write this html
    <%  }%>
    

    There is also

    This <%=SomeVar %> Which will out put SomeVar to HTML

提交回复
热议问题