Escaping ASP.NET Tags in Code Smith Templates

I love to generate code, I have code templates for Code Smith that are the equivalent of a mold for a machine shop. I use them to create thousands upon thousands of lines of code each week, so I guard them with my life and update them almost as often as I update my applications I think.

Code Smith uses the same syntax as ASP.NET to build code generating templates. So one thing I had to learn to overcome was dealing with <%  %> tags in Code Smith, or escape ASP.NET tags in my Code Smith templates. The answer is to use a %% so it would look like <%% %%>.

<td 

class

=

"ListTitle"

> <a href=

'<%%# String.Format("AddEdit<%= sTableName %>.aspx?<%= sTableName %>id={0}", Eval("<%= sTableName %>Id")) %%>'>

<%%#Eval(

"<%= sTableName %>"

)%%></a></td>

Share This Article With Your Friends!

We use cookies to give you the best experience possible. By continuing, we'll assume you're cool with our cookie policy.

Install Love2Dev for quick, easy access from your homescreen or start menu.

Googles Ads Facebook Pixel Bing Pixel LinkedIn Pixel