asp.net.ph

Skip Navigation LinksHome > Getting Started > ASP.NET Syntax > ASP.NET Page Syntax > Code Render Blocks

Code Render Blocks


A code render block defines inline code or inline expressions that execute when the page is rendered.

  • the symbols <% and %> are used to delimit or set the bounds of <% inline code %>.
  • the symbols <%= and %> are used to delimit <%= inline expressions %>.

Code render blocks are declaratively set within the document body, and are mainly used to custom-control page content generation.

Remarks

Any fragment of code ( such as statements, variables, operators, control structures such as conditionals, loops, etc. ) that is valid for the programming language set for the page, may be included within the <% inline code %> delimiters.

ASP.NET executes inline code as a whole and displays the output of the code render block when the page is rendered at runtime.

Likewise, any fragment of code that is valid for the programming language set for the page may be included within the <% inline code %> delimiters.

ASP.NET uses the output directive to evaluate and display the value of an expression when the page is rendered at runtime.

NOTE: The character sequence <% and %> or <%= and %> cannot be included anywhere inside code render block delimiters. Otherwise, an error will occurs at compile time.

Syntax Example

The below code snippet shows how you can use both <% inline code %> and <%= inline expressions %> to display the same HTML text in a number of different font sizes.

<% for ( int i=0; i<8; i++ ) { %>
     <font size = "<%= i %>"> Hello World! 
<% } %>
  C# VB
Code Render Block Example
Run Sample | View Source
See Also

Code Declaration Blocks   Authoring an ASP.NET Page



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note