基页或Base母版页或嵌套的大师? [英] Base Page or Base Master Page or Nested Masters?

查看:148
本文介绍了基页或Base母版页或嵌套的大师?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个母版页网站:一对一栏布局,一个用于两栏布局。这些嵌套母版页,提供了一个共同的页眉和页脚中。

I've got a site with two master pages: one for one-column layout and one for two-column layout. These are nested within a master page that provides a common header and footer.

我有,我想每个内容页面有功能;我应该:

I have functionality that I want each of the content pages to have; should I:


  • 创建一个页面基类,并继承我的内容页面里面,或者

  • 创建一个母版页基类,并继承里面我嵌套母版页的水平之一?

我最终想要的内容页面有机会获得一个连接对象,并说我要被实例化,因为每个页面加载的配置对象。

Ultimately I want the content pages to have access to a connection object and to a configuration object that I want to be instantiated as each page loads.

推荐答案

母版页应只用于在我看来,布局。

Master pages should only be used for layouts in my opinion.

如果你想要做的工作,例如创建连接,这样做在一个基类。

If you want to be doing work such as creating connections, do that in a base class.

但是,您不能创建在你的页面开始一个数据库连接,并在年底关闭它是非常重要的。你应该打开和关闭连接当你运行单个查询。这使得连接池,以提高工作效率。

However, it is important that you not create a database connection at the start of your page, and close it at the end. You should be opening and closing connections as you run individual queries. This allows connection pooling to work efficiently.

此外,我不会把任何类型的网页本身的连接,只要你想你的功能,尽可能从布局中分离出来。

Additionally, I would not be putting a connection of any type in the page itself, as you want to separate your functionality as much as possible from the layout.

这篇关于基页或Base母版页或嵌套的大师?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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