DNN:如何将 .html 模板文件包含到另一个 .html 模板文件中
DNN: How to include .html template file into another .html template file
我正在搜索类似于 PHP 代码但针对 DNN 模板的内容:
<div class="included">
<?php include_once('another.html'); ?>
</div>
试试这个:
<div class="included">
<!--#include file="another.html"-->
</div>
您在其中使用它的文件需要由 ASP.NET 执行,例如 .asp 或 .aspx 文件。如果您的文件是普通 HTML 文件,您应该能够将扩展名更改为 .asp 或 .aspx。您提取的文件实际上可以是任何内容(文本、HTML、XML 等)。
您可能还需要在您的 IIS 设置中启用服务器端包含才能使其正常工作。
我可以提供几个可能的选择:
1) 服务器端,如果您有权访问 .ascx。
<asp:Literal ID="litNewsIncludes" runat="server" />
<%
StreamReader sr = File.OpenText("~/Portals/0/includes/news.html");
litNewsIncludes.Text = sr.ReadToEnd();
sr.Close();
%>
2) 客户端选项使用 jquery ajax 加载 html
<div id="divNewsIncludes"></div>
<script type="text/javascript">
$("#divNewsIncludes").load("/Portals/0/includes/news.html");
</script>
我正在搜索类似于 PHP 代码但针对 DNN 模板的内容:
<div class="included">
<?php include_once('another.html'); ?>
</div>
试试这个:
<div class="included">
<!--#include file="another.html"-->
</div>
您在其中使用它的文件需要由 ASP.NET 执行,例如 .asp 或 .aspx 文件。如果您的文件是普通 HTML 文件,您应该能够将扩展名更改为 .asp 或 .aspx。您提取的文件实际上可以是任何内容(文本、HTML、XML 等)。
您可能还需要在您的 IIS 设置中启用服务器端包含才能使其正常工作。
我可以提供几个可能的选择:
1) 服务器端,如果您有权访问 .ascx。
<asp:Literal ID="litNewsIncludes" runat="server" />
<%
StreamReader sr = File.OpenText("~/Portals/0/includes/news.html");
litNewsIncludes.Text = sr.ReadToEnd();
sr.Close();
%>
2) 客户端选项使用 jquery ajax 加载 html
<div id="divNewsIncludes"></div>
<script type="text/javascript">
$("#divNewsIncludes").load("/Portals/0/includes/news.html");
</script>