主文件是否可替代整体布局的用户控件? [英] Are master files a replacement for user controls for overall layout?

查看:42
本文介绍了主文件是否可替代整体布局的用户控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


在经典ASP中,我曾经在每个页面上使用两个包含文件,一个在

之前,一个在主要内容之后,在

网站上提供一致的布局。这样我就可以更改包含文件来更改

布局。当我来到ASP.NET时,我使用用户控件来做类似的

的事情。


我刚刚看过母版页,看起来很像就像他们做同样的事情一样。如果是这样,使用它们对用户有什么好处

控件?显然母版页允许你有一个文件而不是两个b
,但这不是一个巨大的优势。我想知道他们到目前为止是否还有更多的价值。


感谢您提供任何信息。


-

Alan Silver

(此行下面添加的任何内容都与我无关)

解决方案

我能想到的一些事情:

- 您可以使用设计师支持创建更多动态布局

- 性能改进,ASP.NET运行时知道MasterPages

- 可从web.config配置


我相信MasterPages出现了一个使用特殊控件的项目&

设计师,所以我认为运行时支持是这里的主要因素..


>我能想到的一些事情:


感谢您的回复,但我不是很清楚;-(

- 您可以创建更多动态布局,使用设计师支持


以何种方式更具活力?你呢?是否可以在运行时更改它们?

如果是这样,为什么用户控件不能这样做?

-性能改进,ASP.NET运行时知道关于MasterPages


运行时也知道用户控件。您是否说使用

母版页提供的性能比使用某些HTML和/或服务器标签的用户控件更好?我不是说你错了,但是我觉得很难相信,因为你要用

母版页添加一层额外的复杂性。 />
- 可从web.config配置


请解释一下你的意思以及为什么这会有用。

我相信MasterPages出现了一个使用特殊控件和设计器的项目,所以我认为运行时支持是这里的主要因素..




感谢您的回复,但我会我在这里欣赏更多信息

我们真的不明白你的意思。


-

Alan Silver

(此行下面添加的任何内容都与我无关)


嗨Alan:


使用母版页,您将永远不必包含一个共同的标题和

页脚。你告诉主页页眉和页脚去哪里和

然后你的内容页面只是插入内容。


您的页眉和页脚可能仍然在里面实现两个用户

控制文件 - 但你永远不必在每个内容页面上布局这两个用户

控件 - 只需在你的主页面上

app。


更有意义吗?


-

Scott
http://www.OdeToCode.com/blogs/scott/

On Sun,2005年10月30日20:48:47 +0000,Alan Silver

< al ********* @ nospam.thanx> ;写道:

你好,

在经典ASP中,我曾经在每个页面上使用两个包含文件,一个在
之前,一个在主要之后内容,在
网站上提供一致的布局。这样我就可以改变包含文件来改变
布局。当我来到ASP.NET时,我使用了用户控件来做类似的事情。

我刚刚看过母版页,看起来他们就是这样做了
一样。如果是这样,使用它们对用户
控制有什么好处吗?显然母版页允许你有一个文件而不是两个文件,但这不是一个巨大的优势。我想知道他们到目前为止还有更多的东西。

感谢您的任何信息。




Hello,

In classic ASP, I used to use two include files on each page, one before
and one after the main content, to provide a consistent layout across a
web site. That way I could just change the include files to change the
layout. When I came to ASP.NET, I used user controls to do a similar
thing.

I have just been looking at master pages, and it looks like they do the
same thing. If so, is there any advantage in using them over the user
controls? Obviously master pages allow you to have one file instead of
two, but that''s not a huge advantage. I''m wondering if there''s more to
them than I have seen so far.

Thanks for any info.

--
Alan Silver
(anything added below this line is nothing to do with me)

解决方案

Some of the things I can think of:
-You can create more dynamic layouts, using designer support
-Performance improvements, the ASP.NET runtime knows about MasterPages
-Configurable from web.config

I believe MasterPages came forth of a project using special controls &
designers, so I think the runtime support is the major factor here..


>Some of the things I can think of:

Thanks for the reply, but I''m not really clearer;-(

-You can create more dynamic layouts, using designer support
More dynamic in what way? Do you mean you can change them at run time?
If so, why can''t you do this with user controls?
-Performance improvements, the ASP.NET runtime knows about MasterPages
The runtime knows about user controls too. Are you saying that using
master pages gives better performance than having a user control with
some HTML and/or server tags in? I''m not saying you''re wrong, but I find
it hard to believe as you are adding an extra layer of complexity with
master pages.
-Configurable from web.config
Please explain what you mean and why this would be useful.
I believe MasterPages came forth of a project using special controls &
designers, so I think the runtime support is the major factor here..



Thanks for the reply, but I would appreciate some more info here as I
don''t really see what you mean.

--
Alan Silver
(anything added below this line is nothing to do with me)


Hi Alan:

With master pages you''ll never have to "include" a common header and
footer. You tell the master page where the header and footer go and
then your content pages just plugin the content.

Your header and footer might still be implemented inside of two user
control files - but you''ll never have to layout those two user
controls on every content page - just on the master page(s) in your
app.

Make more sense?

--
Scott
http://www.OdeToCode.com/blogs/scott/
On Sun, 30 Oct 2005 20:48:47 +0000, Alan Silver
<al*********@nospam.thanx> wrote:

Hello,

In classic ASP, I used to use two include files on each page, one before
and one after the main content, to provide a consistent layout across a
web site. That way I could just change the include files to change the
layout. When I came to ASP.NET, I used user controls to do a similar
thing.

I have just been looking at master pages, and it looks like they do the
same thing. If so, is there any advantage in using them over the user
controls? Obviously master pages allow you to have one file instead of
two, but that''s not a huge advantage. I''m wondering if there''s more to
them than I have seen so far.

Thanks for any info.




这篇关于主文件是否可替代整体布局的用户控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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