Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

CodeSmith Basic Syntax - Escape Asp.Net tag


May 25, 2021 CodeSmith


Table of contents


Basic syntax - escape Asp.Net tags

Because CodeSmith's code template uses a syntax similar to Asp.Net Asp.Net's, if you want to use the CodeSmith template to generate a Asp.Net script, such as the ""

This is done by replacing the slt;% tag in the Asp.Net that needs to be generated.

For example, we're going to generate Asp.Net code like this:

<asp:FormView ID="FormView1" DataSourceID="SqlDataSource1" DataKeyNames="ProductID" RunAt="server">
  <ItemTemplate>
    <table>
      <tr>
        <td align="right"><b>Product ID:</b></td>       
        <td><%# Eval("ProductID") %></td>
      </tr>
    </table>                 
  </ItemTemplate>                 
</asp:FormView>

You can replace it with a template for CodeSmith, using slt;%%

<asp:FormView ID="FormView1" DataSourceID="SqlDataSource1" DataKeyNames="ProductID" RunAt="server">
  <ItemTemplate>
    <table>
      <tr>
        <td align="right"><b>Product ID:</b></td>       
        <td><%%# Eval("ProductID") %></td>
      </tr>
    </table>                 
  </ItemTemplate>                 
</asp:FormView>