虽然服务器端的classic ASP方法包括在ASP.NET中工作,但我得到的印象是它不是首选的方法.我怎么"应该"达到同样的效果呢?
This is how I'm doing it at the moment:
<!-- #include file ="functionlib.aspx" -->
虽然服务器端的classic ASP方法包括在ASP.NET中工作,但我得到的印象是它不是首选的方法.我怎么"应该"达到同样的效果呢?
This is how I'm doing it at the moment:
<!-- #include file ="functionlib.aspx" -->
现在有很多选项可以提供这种效果,但方式不同.
每种方法都有不同的用途,以实现不同的目标.这取决于你真正想做什么.给定include文件的名称,我可以想象您正在try 包含将在页面上下文中使用的库函数.
因此,您需要编写一个包含这些方法的类库,并将它们导入到您的应用程序/aspx中.
如果你正在寻找一个模板页面,它将完成大部分的布局工作,为不同的内容提供一个主体,那么你会对母版页感兴趣.
如果您正在寻找可以在多个页面中使用的模板控件,那么您将会关注用户控件.
如果您正在研究跨多个项目的多个用户可以使用的模板控件,那么您将研究服务器端控件.
If you're looking at a library of classes/methods then you'll develop a class library or use an app_code class which can be JIT compiled the first time it's called. This could at a stretch be considered more like classic ASP, but really it functions more like a class from a class library as a single unit. You can call it from within your codebehind or within <% %> tags in your aspx/ascx code without requiring a reference to a class library.
我们不再真正使用"包含"本身,但工具箱中的每一个工具都允许您为不同的场景提供类似的概念.作为开发人员,您将以不同的方式与网页的整个页面生命周期进行交互.ASP.NET与传统的ASP是截然不同的.它确实采取了不同的观点/方法,需要一定的耐心才能找出差异.