Escaping ASP.NET Tags
If you're building ASP.NET code with CodeSmith Generator , you'll run into the problem that the <% tags that you want to output to your ASP.NET code are interpreted by CodeSmith Generator as CodeSmithtags instead. The solution is to escape the starting tags, replacing <% with <%%. This will be replaced with <% in the output, and not seen by CodeSmith Generator as an opening script tag.
Example
In this example we will escape the ASP.NET tags as shown in the following example:
<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>
As stated above to escape the eval statement (<%# Eval("ProductID") %>) all you need to do is write it as follows:
<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>