Click here to Skip to main content
15,891,976 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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
Posted

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.
 
Share this answer
 
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.
 
Share this answer
 
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
 
Share this answer
 
Comments
virendersingh10289 24-May-12 2:52am    
gd one!!!!!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900