我可以使用存储在webform.aspx中的包含文件(例如test.inc)中的脚本



我可以使用存储在include文件(例如test.inc)中的脚本中的webform.aspx?如果答案是我的做法是,我对我这样的替代方式提出了我的问题:

//----- Footer.inc ------
 Copyright <% DateTime.Now.Year %> , My Company Name .
 ---------------  
   // ----- Default.aspx ----
          <td class="ColRightStyle" colspan="2">
               <% Response.WriteFile("Includes/Footer.inc"); %>
          </td>

但导致浏览器为:

版权所有&lt;%datetime.now.year%>,我的公司名称。

(右=>版权所有2014,我的公司名称。)

我花时间搜索相关的问题,但我没有找到问题和回答TNX SO Mush

您可以使用以下方式:

<td class="ColRightStyle" colspan="2">
                    <% Response.WriteFile("Includes/Footer.inc"); %>
                </td>

and in footer.inc文件:

<div class="FooterStyle" dir="rtl" >
       Copyright , Notice &nbsp; &copy;
        <br /></div>
        <div class="FooterStyle" dir="ltr"  >
        &copy;&nbsp;Copyright by www.Google.com ; 2004 - <% =DateTime.Now.Year %>

    </div>

我不知道您为什么要这样做,可以阅读文件内容并解析它,但它仍然不会给您所寻求的东西。例如:<% DateTime.Now.Year %>应为<%= DateTime.Now.Year %>,以获取所需的值,该值不符合PHP INC文件。

但是,如果要这样做,则可以使用自定义表达式构建器
这是一篇涵盖主题的文章

顺便说一句,如果您想阅读内容,请尝试以下操作:

System.IO.File.ReadAllText(Server.MapPath("~/Include/Footer.inc"))

相关内容