我用CodeSmith生成ASPX页面,遇到了字符转义问题,请会的兄弟帮一下
大家都知道CodeSmith的变量用<%=XXX%>这样的定义的,但ASPX的绑定语法也是类似
<%# Bind("XXX")...,这样就和CodeSmith冲突了
还有在生成C#代码的时候和类似IView<<%=XXX%>>这样的代码冲突,CodeSmith不认识<<%字符,请问大家是如何解决此类问题的?

解决方案 »

  1.   

    IView< <%=XXX%> >
    我都是这样写的
      

  2.   

    那么<%# Bind("XXX")%> 如何做呢
      

  3.   

    按照帮助里面的说法,Q: I am generating ASP.NET code from my templates and the ASP.NET tags are causing CodeSmith to get confused. A: Change the ASP.NET tags to <%% instead of <%, this will escape the tag and allow it to be passed down to the output of the template instead of being processed as template code.就是你所有的ASP.NET的标签都要写成<%%开头,而CodeSmith变量用<%开头,这样就不冲突了。
      

  4.   

    我把"<%"定义成了一个变量来用
    <%
    string lperc="<%";
    %>
    <%=lperc%>@ Page Language="C#" MasterPageFile="~/Manage/Manage.master" AutoEventWireup="true"
        CodeFile="Manage_U_Role.aspx.cs" Inherits="Manage_U_Role" Title="??" %>