相当于 ASP Classic 中的母版页 [英] Equivalent to master pages in ASP Classic

查看:38
本文介绍了相当于 ASP Classic 中的母版页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 Classic ASP 没有框架或 iframes 来构建某种母版页?

Is it possible to build some kind of master page with Classic ASP without frames or iframes?

我想知道是否有办法在主页中包含内容页面,例如 ASP.NET母版页就可以了.根据我的研究,ASP Classic 确实支持将其他 ASP/HTML 页面包含到一个页面中,但是放入这个 include 的值意味着该功能不能是动态的.

I’m wondering if there is a way to include content pages in the main page like ASP.NET master pages do. From what I have researched, ASP Classic does support inclusion of other ASP/HTML pages into a page, but the value put into this include means the function cannot be dynamic.

推荐答案

你可以只创建函数(比如,一个 Header() 函数和一个 Footer() 函数) 除了输出一些标记集之外什么都不做.这些函数也可以带参数,并有条件地调用.它与母版页不太一样,但听起来它完成了您想要做的事情.您将在每个页面上都有一个 <!--#include file="headerfooter.asp"-->,并且每个页面都会调用 Header() &Footer().

You could just create functions (say, a Header() function and a Footer() function) which do nothing but output some set of markup. Those functions can take parameters too, and be called conditionally. It's not quite the same as a Master page, but it sounds like it accomplishes what you are trying to do. You would have an <!--#include file="headerfooter.asp"--> on each page, and each page would call Header() & Footer().

或者您可以在顶部使用 <!--#include file="header.asp"--><!--#include file="footer.asp"--> 也在每个页面的底部.这两种方法我都见过.

Or you can just use <!--#include file="header.asp"--> at the top and <!--#include file="footer.asp"--> at the bottom of each page too. I've seen both approaches.

如果您正在寻找相反的内容,即在中间"部分调用单个页面的单个模板页面,那么这并不是您可以使用 ASP classic 轻松完成的事情.这是方法上的根本区别:ASP.NET 具有控件树、事件等的概念,而 ASP Classic 本质上只是一个自上而下运行的脚本.

If you are looking for the reverse, that is, a single template page which calls individual pages in it's "middle" section, then that's not really something you can do easily with ASP classic. It's a fundamental difference in approach: ASP.NET has a concept of a control tree, events, etc, while ASP Classic is essentially just a script that runs top to bottom.

这篇关于相当于 ASP Classic 中的母版页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆