用户控制与主页面哪一个更好,为什么 [英] user control vs master page which one is better and why

查看:64
本文介绍了用户控制与主页面哪一个更好,为什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户控制与主页哪一个更好,为什么?

user control vs master page which one is better and why?

推荐答案

你无法比较它们:它们的用途非常非常不同。 br />
母版页允许您的整个网站共享一个共同的外观和感觉,可以非常轻松地更改或更正,而不会影响或更改内容。

用户控件允许代码在应用程序中重用和封装功能,无论是基于Web还是基于PC。



他们不是一回事,不做同样的工作,而且可以不能以任何有意义的方式进行比较。
You can't compare them: they are meant for very, very different purposes.
Master pages allow your entire website to share a common "look and feel" which can be changed or corrected very easily, without impacting or changing the content.
User Controls allow code reuse and encapsulation of functions within an application, be it web or PC based.

They aren't the same thing, don't do the same job, and can't be compared in any meaningful way.


你正在比较苹果和橘子。母版页允许所有页面围绕它们使用相同的包装,因此站点的主结构和header \ footer可以进入母版页,并且各个页面只需要包含特定于该页面的内容,并且母版页内容为包裹它。



用户控件是指你想在多个页面上放置相同的元素,就像你把asp:GridView放在你要显示的地方一样表格数据。假设您有一个电子商务网站,您可以开发一个产品摘要控件,在一个小方框中显示产品图像和标题,价格等,您可以在搜索结果页面,购物篮页面,主页上使用该控件。 ...您想要显示产品摘要的任何地方。
You're comparing apples and oranges. Master pages allow all your pages to have the same wrapper around them, so the site's main structure and header\footer can go in the master page and the individual pages only need to contain the things specific to that page and the master page content is wrapped around it.

A user control is when you want to put the same element on multiple pages, the same way you put an asp:GridView where you want to show tabular data. Let's say you have an ecommerce site you might develop a "Product Summary" control that shows the product image and title, price etc in a small box and you can use that control on search results pages, on the basket page, the home page....anywhere you want to show a product summary.


这篇关于用户控制与主页面哪一个更好,为什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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