| 1 | <h2>Comments</h2> |
| 2 | <pre><code><%-- This is a comment --%> |
| 3 | <%-- This is a |
| 4 | multi-line comment --%></code></pre> |
| 5 | |
| 6 | <h2>Page directives</h2> |
| 7 | <pre><code><%@ Page Title="Products" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ProductList.aspx.cs" Inherits="WingtipToys.ProductList" %> |
| 8 | </code></pre> |
| 9 | |
| 10 | <h2>Directive tag</h2> |
| 11 | <pre><code><%: Page.Title %> |
| 12 | <a href="ProductDetails.aspx?productID=<%#:Item.ProductID%>"> |
| 13 | <span> |
| 14 | <%#:Item.ProductName%> |
| 15 | </span></code></pre> |
| 16 | |
| 17 | <h2>Highlighted C# inside scripts</h2> |
| 18 | <p>This requires the C# component to be loaded. |
| 19 | On this page, check C# <strong>before</strong> checking ASP.NET should make |
| 20 | the example below work properly.</p> |
| 21 | <pre><code><script runat="server"> |
| 22 | // The following variables are visible to all procedures |
| 23 | // within the script block. |
| 24 | String str; |
| 25 | int i; |
| 26 | int i2; |
| 27 | |
| 28 | int DoubleIt(int inpt) |
| 29 | { |
| 30 | // The following variable is visible only within |
| 31 | // the DoubleIt procedure. |
| 32 | int factor = 2; |
| 33 | |
| 34 | return inpt * factor; |
| 35 | } |
| 36 | </script></code></pre> |