ASP.NET等效服务器侧包括 [英] ASP.NET equivalent of server side includes

查看:140
本文介绍了ASP.NET等效服务器侧包括的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然服务器端的传统的ASP方法包括ASP.NET的作品,我得到的IM pression它不是preferred方法。我如何应该可以达到同样的效果?

Although the classic ASP method of server-side includes works in ASP.NET, I get the impression it is not the preferred method. How am I "supposed" to be achieving the same effect?

这是我正在做的那一刻:结果
<! - #包括文件=functionlib.aspx - >

This is how I'm doing it at the moment:
<!-- #include file ="functionlib.aspx" -->

推荐答案

您现在有许多用于提供这种效果的选择,但以不同的方式。

You now have a number of options that provide this effect, but in a different manner.


  • 用户控件(的.ascx)

  • 母版页(的.master)

  • 服务器端控件文件(.dll)

  • 类库文件(.dll)

  • APP_ code类(的.cs /的.vb)

每个用于不同,以实现不同的事情。这取决于你真正想要做的事。鉴于您的包含文件的名称,我想像你想包括将你的页面的上下文中使用的库函数。

Each are used for differently to achieve different things. It depends what you're really trying to do. Given the name of your include file, I'd imagine you're trying to include library functions that will be used within the context of your page.

因此​​,你会写一个包含方法的类库,并将其导入到应用程序/ ASPX。

Consequently you'd write a class library that contains the methods and import them into your application/aspx.

如果你正在寻找模板化的网页,将完成大部分的布局工作,为不同的内容,那么你会感兴趣的母版页提供机构。

If you're looking at templating a page that will do most of the layout work to provide a body for differing content then you'll be interested in Master Pages.

如果你正在寻找的,可以在许多页面中使用模板的控件,那么你将成为用户控件后。

If you're looking at templating controls that can be used in many pages, then you're going to be after User Controls.

如果您正在寻找能够通过在很多项目很多用户使用模板控件,那么你将着眼于服务器端控件。

If you're looking at templating controls that can be used by many users across many projects, then you'll be looking at Server Side Controls.

如果您正在寻找的一个类库/方法,那么你将开发一个类库或使用可JIT编译第一次,它被称为一个APP_ code类。这的可能的一气被认为更像是传统的ASP,但实际上它的功能更像是从一个类库作为一个单元的类。您可以从codebehind内或在&LT调用它。在你的ASPX / ASCX code%%>标签,而不需要一个类库的引用

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。这确实需要一个不同的观点/方法,并会采取耐心的一定量的计算出的差异。

We don't really use "includes" per se any more, but each of these tools in your toolkit allow you to provide similar concepts for different scenarios. As a developer you will interact with the entire page lifecycle of your web pages differently. ASP.NET is a very different beast than classic ASP. It truly takes a different view/approach and will take some amount of patience to figure out the differences.

这篇关于ASP.NET等效服务器侧包括的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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