简体   繁体   English

从计算机上的模板加载HTML页面

[英]Loading html page from a template on the computer

I am working with a C# on visual studios. 我正在视觉工作室上使用C#。

What I would like to know is if it is possible to have a html template loaded from a directory on my computer. 我想知道的是,是否可以从计算机上的目录中加载html模板。 Then every time I load up my code it will load up the .html template automatically. 然后,每次我加载代码时,它将自动加载.html模板。

Yes there is a way, not suggested but exist. 是的,有一种方法,不建议使用,但存在。 You can use this code to include the file, inside your asp.net page. 您可以使用此代码将文件包含在asp.net页面中。

<!--#include file="template.htm"--> 

What is dose is that is load this htm file and show it on the place that you have place this declaration. 剂量是将这个htm文件加载并显示在您放置此声明的地方。 Also you must know that this file can not contain anything dynamically. 另外,您必须知道该文件不能动态包含任何内容。 This is a command code that comes from the old asp script code, and still work on asp.net 这是来自旧的ASP脚本代码的命令代码,仍然可以在asp.net上使用

So I can not call it as template. 所以我不能称其为模板。 If you wish to make something like a real template you must use a master page. 如果要制作类似真实模板的内容,则必须使用母版页。 Using a master page is far better, and you just copy paste your htm code inside the master page and there you have it. 使用母版要好得多,您只需将htm代码复制粘贴到母版中即可。

relative: http://triaslama.wordpress.com/2008/11/19/how-to-include-file-in-aspnet-pages/ 相对的: http//triaslama.wordpress.com/2008/11/19/how-to-include-file-in-aspnet-pages/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM