用户控制和母版页 [英] user control and master page

查看:79
本文介绍了用户控制和母版页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



用户控件和母版页之间的主要区别是什么?
实际上,当这些实现时,我有点困惑.
我知道上述两种控件都可以多种形式使用.
由于两者都可以使用多种形式.在哪里需要两个控件?
我对控件的功能感到困惑.
我在Google上进行了搜索,但找不到正确的区别..

请让我知道用户控件和母版页之间的区别

Hi,

What is the main difference between user control and master page?
Actually I am little bit confused that when these are implemented.
I know that both the above controls, can be used in multiple forms.
As both can be used multiple forms. where is the need of having two controls?
I am confused with the functionality of controls.
I searched in the Google but I couldn''t get the correct difference..

Please let me know the difference between user control and master page

推荐答案

^ ]就像模板一样,就像在ASP.NET母版页中一样,允许您为应用程序中的页面创建一致的布局.作为A 用户控件 [
Master Page[^] is act like template as in ASP.NET master pages allow you to create a consistent layout for the pages in your application. where as A user control [^]is a kind of composite control that works much like an ASP.NET Web page—you can add existing Web server controls and markup to a user control, and define properties and methods for the control. You can then embed them in ASP.NET Web pages, where they act as a unit.
In short A Master Page always act as template and the merging container for the web pages and controls whereas a User Control is always a control which can be used again in many pages.


实际上,您不能将母版页与用户控件进行比较.它们没有任何关系.母版页是为多个表单提供相同视图的页面.因此,例如,如果您有2个带有菜单的页面,则可以将此菜单放在母版页中,并使这2个页面成为该母版页的子级,以便他们可以获取菜单控件.尽管用户控件是您为了在很多地方使用它而不必再次编写相同代码的控件,但是例如,您可以使一个带有标签且其文本为hello的用户控件.因此,现在您可以将该控件拖放到任何表单上,并且可以看到该标签.与您可以使用用户控件进行的操作相比,Offcourse只是一个小示例,因此,例如,我制作了一个用户控件一次的滑块,并通过拖放操作在许多站点中使用了它,而不是再次编写所有内容.无论如何以获取更多信息,请访问那些链接:

资料页:

http://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx [ ^ ]

用户控件:

http://msdn.microsoft.com/en-us/library/y6wb1a0e.aspx [ ^ ]

祝你好运,请不要将无关的东西混在一起.
Actually you cannot compare a master page to a user control.They have no relation. A master page is a page that provides the same view for multiple forms. So for example if you have 2 pages that have a menu, then you put this menu in a master page, and make those 2 pages children of this master page so they can get the menu control. While a user control is a control that you make in order to use it in many places without having to write the same code again, so for example you can make a user control that has a label and its text is hello. So now you can drag and drop this control on any form and you will be able to see this label. Offcourse this is a small example compared to what you can do with user control, so for example i made a slider once a user control and used it in many sites by just drag and drop instead if writing everything again. Anyway for further info visit those links :

Mater page :

http://msdn.microsoft.com/en-us/library/wtxbf3hh.aspx[^]

User control :

http://msdn.microsoft.com/en-us/library/y6wb1a0e.aspx[^]

Good luck and please dont mix unrelated things together.


好吧,我会给你简单的例子.

看一下该页面的上半部分,您可以在其中看到Code Project的徽标以及诸如首页",文章",讨论"之类的选项卡.该部分称为母版页.母版页主要用于显示站点的菜单以及开发人员希望在每个页面(也许是所有页面)上显示的内容.

用户控件确实会经常更改.查看此页面的最上方.您将在此处看到您的登录名或用户名,包括您的积分和退出"按钮.这实际上不是 User Control ,但其工作与 User Control 相同,后者大部分时间都会更改.就像2个控件一样,它们会根据登录状态和登录者进行更改.

希望你能从这里得到它.

问候,
爱德华
Ok i will give you easy examples for this one.

Take a look at the upperpart of this page where you can see the logo of Code Project and tabs like: Home, Article, Discussion, etc. This part is called the Master Page. Master pages are used basically to show the site''s menu and those things that developer would want to show on each and every, perhaps all pages.

User Controls do often change. Look at the uppermost part of this page. You will see there your Login name or your username including your points and the Signout button. This isn''t actually a User Control but the work of this is just as the same with User Control which changes most of the time. It is like 2 controls which change based on Login status and whoever is logged in.

Hope you get it from here.

Regards,
Eduard


这篇关于用户控制和母版页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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